本文介绍了是否有确定点和矩形之间关系的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有点坐标和矩形(或多边形),如何知道点是否位于矩形内?
suppose i have Point coordinates and a rectangle(or polygon),how to know whether a point lies inside a rectangle or not?
推荐答案
private Rectangle boundRect;
private Region testRegion;
private Point testPoint;
private bool IsInRect;
private bool IsInRegion;
private void TestHitDetection()
{
boundRect = this.ClientRectangle;
testRegion = new Region(new Rectangle(50,50, 200,200));
testPoint = new Point(100,100);
IsInRect = boundRect.Contains(testPoint);
IsInRegion = testRegion.IsVisible(testPoint);
}
imho命中检测操作符的MS名称命名非常差。
imho the MS names for the hit-detection operators are very poorly named.
这篇关于是否有确定点和矩形之间关系的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!