How to detect if an ellipse intersects(collides with) a circle

后端 未结 10 2572
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-09 03:41

I want to improve a collision system.

Right now I detect if 2 irregular objects collide if their bounding rectangles collide.

I want to obtain the for recta

10条回答
  •  情深已故
    2020-12-09 04:05

    This isn't that hard. user168715's answer is generally right, but doing calculus isn't necessary. Just trigonometry.

    Find the angle between the center of the two objects. Using this you can find the closest point to the circle's center on the ellipse using the polar-form:

    Ellipse Equation : Polar form relative to center

    (Taken from Wikipedia article on Ellipses)

    Now compare the distance between the two object centers, subtracting the ellipse radius and circle radius.

    Maybe I'm missing something; maybe ArcTan/Cos/Sin are slow -- but I don't think so, and there should be fast-approximations if needed.

提交回复
热议问题