有这个的CRgn::PtInRegion This method checks whether the point specified by x and y is in the region stored within the CRgn object.BOOL PtInRegion( int x, int y ) const; BOOL PtInRegion( POINT point ) const; 或者 BOOL PtInRegion( HRGN hrgn, // handle to region int X, // x-coordinate of point int Y // y-coordinate of point );一个点是否在某个区域内
BOOL PtInRect(
POINT point
) const throw( );
This method checks whether the point specified by x and y is in the region stored within the CRgn object.BOOL PtInRegion(
int x,
int y )
const; BOOL PtInRegion(
POINT point )
const; 或者
BOOL PtInRegion(
HRGN hrgn, // handle to region
int X, // x-coordinate of point
int Y // y-coordinate of point
);一个点是否在某个区域内
加油…………
|x1 x2 x3|
则S(A,B,C) =abs( |y1 y2 y3| )= (x1-x3)*(y2-y3) - (y1-y3)*(x2-x3)
|1 1 1 |
解决:
设要判断的点为P,凸多边形为A1A2A3、、、An(顺时针或逆时针都可以),
首先计算S = S(A1,A2,A3) + S(A1,A3,A4) + 、、、+S(A1,An-1,An)
然后计算SS = S(P,A1,A2) + S(P,A2,A3) + 、、、+ S(P,An,A1)
最后判断S与SS的关系,
若S=SS,则P在该凸多边形的边上或内部
P在第i边上的附加条件是S(P,Ai,Ai+1)=0
若S<SS,则P在该凸多边形的外部
S>SS的情况是不存在的。