Jump to content
  • Advertisement
Sign in to follow this  
amish1234

ellipse collision detection

This topic is 5035 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
Advertisement
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
Didnt follow the link so this may have already been solved by the second poster, but, yeah. the common method should be to transform your ellipse to a unit spehere and apply the same transform to your other geometry you will test.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!