怎样判断一个点在椭圆内部?
我根据椭圆方程写了如下函数判断点(ri_x,ri_y)是否在椭圆内部,
但是椭圆的水平和垂直半径太大的时候会超出32位整数范围,因为性能问题不能用64位整数或者浮点数,
请大家帮我想下有什么好的算法,谢谢!
static int IsPixelInEllipse(
int ri_X,
int ri_Y,
int ri_CentreX,
int ri_CentreY,
int ri_HRadius,
int ri_VRadius)
{
int i_X;
int i_Y;
unsigned long i_SquareA;
unsigned long i_SquareB;
i_X = ri_X - ri_CentreX ;
i_Y = ri_Y - ri_CentreY ;
i_SquareA = ri_HRadius * ri_HRadius ;
i_SquareB = ri_VRadius * ri_VRadius ;
return i_SquareB * ( i_X * i_X) + i_SquareA * ( i_Y * i_Y) <= i_SquareA * i_SquareB;
}