开发者

How to detect if an ellipse collides with an another ellipse / rectangle

开发者 https://www.devze.com 2023-03-20 17:34 出处:网络
I want to detect if ellipse collides with another ellipse and rectangle. How I can do it? I\'m writing in C++. I want to use i开发者_JAVA技巧t for a game.If this is for a game, then exactness should

I want to detect if ellipse collides with another ellipse and rectangle. How I can do it?

I'm writing in C++. I want to use i开发者_JAVA技巧t for a game.


If this is for a game, then exactness should not be an issue. Treat your ellipse as a polygon, that is, choose N evenly distributed points on your ellipse and treat is as a polygon. Adjuct N to the level of the desired correctness.

Now you need to test if a convex polygon collides with a rectangle. And the latter is a convex polygon as well. Here's a link for convex polygon collision detection


If you need precise answer, than you have to describe your figures as functions and use Newton's method for finding intersection points

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号