有三个点 A, B, C
A:CPoint point;
B: CPoint ltPoint;
C: CPoint rbPoint;
怎么判断点A 是否在以点B为左上角,C为右下角组成的矩形所确定的椭圆里面?

解决方案 »

  1.   

    椭圆边上的点到椭圆的两个焦点的距离和为定值
    a调这两个点距离和大于定值在椭圆外,否则在椭圆内
    定值=c.x-b.x
      

  2.   

    呵呵,俺找到答案了。
    定义一个CRgn rgn;
    rgn.CreateEllipticRgn(A,B);
    if (PtInRegion(rgn, point))
    ^_^!!!
      

  3.   

    先用这个API函数创建一个椭圆形的区域
    HRGN CreateEllipticRgn(    int nLeftRect, // x-coordinate of the upper-left corner of the bounding rectangle 
        int nTopRect, // y-coordinate of the upper-left corner of the bounding rectangle 
        int nRightRect, // x-coordinate of the lower-right corner of the bounding rectangle  
        int nBottomRect  // y-coordinate of the lower-right corner of the bounding rectangle  
       ); 然后用下面的API函数确定点是否在区域内:BOOL PtInRegion(    HRGN hrgn, // handle of region 
        int X, // x-coordinate of point  
        int Y  // y-coordinate of point  
       );