Circle – Line Intersection工作不正常?

我在http://mathworld.wolfram.com/Circle-LineIntersection.html之后写了这个圆线交叉检测,但看起来好像它或我遗漏了一些东西。

public static bool Intersect (Vector2f CirclePos, float CircleRad, Vector2f Point1, Vector2f Point2) { Vector2f p1 = Vector2f.MemCpy(Point1); Vector2f p2 = Vector2f.MemCpy(Point2); // Normalize points p1.X -= CirclePos.X; p1.Y -= CirclePos.Y; p2.X -= CirclePos.X; p2.Y -= CirclePos.Y; float dx = p2.X - p1.X; float dy = p2.Y - p1.Y; float dr = (float)Math.Sqrt((double)(dx * dx) + (double)(dy * dy)); float D = p1.X * p2.Y * p2.X - p1.Y; float di = (CircleRad * CircleRad) * (dr * dr) - (D * D); if (di < 0) return false; else return true; } 

它返回true的唯一场合是Point2正在使用圆圈。 我究竟做错了什么?

 float D = p1.X * p2.Y * p2.X - p1.Y; 

你已经在这条线上混淆了你的运营商。