Sign in to follow this  

ellipse collision detection

This topic is 4824 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am writing a program that involves a point bouncing around inside an ellipse, and I'm having trouble telling when the point has hit the edge of the ellipse. The ellipse is centered at the origin. Here's psuedocode of my if statement that checks for collisions. if(point.x >= cos(angle_point_makes_with_origin)*Ellipse.XRadius && point.y >= sin(angle_point_makes_with_origin)*Ellipse.YRadius) I don't see what's wrong with this. Does anyone else?

Share this post


Link to post
Share on other sites
I think it's possible to reduce this problem to a point in unit sphere problem which should be quite easy to solve - try to devide the point x/y position though the elipse radi...

Have a look at http://www.peroxide.dk/papers/collision/collision.pdf -
section 'Ellipsoid space'. (I like this really nice trick :)

Share this post


Link to post
Share on other sites
This is just a 2D ellipse, so I'm not sure if the sphere stuff applies. I could apply the transformation stuff, especially since the program starts off with a circle and I keep track of the ellipse by scaling the circle on each axis.

What I'd really like though is a function that could take in an angle as a parameter and return a 2D vector that contains the radii of the ellipse at that angle.

Share this post


Link to post
Share on other sites
Ok, I figured it out. I basically used the pythagorean theorem:

if(point.x*point.x + point.y*point.y >= cos(angle_point_makes_with_origin)*Ellipse.XRadius)^2 +(angle_point_makes_with_origin)*Ellipse.YRadius)^2)

(I used ^ like in math just to make it shorter).

Most of my problems actually came from other parts of the code.

Share this post


Link to post
Share on other sites

This topic is 4824 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this