求一个算法:点是否在一个不规则多边形内
求一个算法:点是否在一个不规则多边形内 问题点数:100、回复次数:4Top
1 楼laiyiling(陌生人[MVP])回复于 2004-09-03 08:59:35 得分 40
http://search.csdn.net/Expert/topic/2390/2390669.xml?temp=.1913568Top
2 楼csdnzhu(我什么也不会)回复于 2004-09-03 09:01:24 得分 50
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=184334
看看这里,我用过了,好用Top
3 楼Gr177(沉默的是人)回复于 2004-09-03 09:01:41 得分 10
先构建一个Rgn,至于如何构建这个Rgn有很多方法,比如可以:CreateFromPath 。
然后就可以使用CRgn::PtInRegion。
MSDN例子:
// Line- and arc-drawing variables
static BOOL bCollectPoints;
static POINT ptMouseDown[32];
static int index;
POINTS ptTmp;
RECT rc;
case WM_LBUTTONDOWN:
if (bCollectPoints && index < 32)
{
// Create the region from the client area.
GetClientRect(hwnd, &rc);
hrgn = CreateRectRgn(rc.left, rc.top,
rc.right, rc.bottom);
ptTmp = MAKEPOINTS((POINTS FAR *) lParam);
ptMouseDown[index].x = (LONG) ptTmp.x;
ptMouseDown[index].y = (LONG) ptTmp.y;
// Test for a hit in the client rectangle.
if (PtInRegion(hrgn, ptMouseDown[index].x,
ptMouseDown[index].y))
{
// If a hit occurs, record the mouse coords.
Marker(ptMouseDown[index].x, ptMouseDown[index].y,
hwnd);
index++;
}
}
break;
Top
4 楼Gr177(沉默的是人)回复于 2004-09-03 09:03:32 得分 0
倒~刚刚看了两位大侠的发贴,我错了!!!Top




