Sign in to follow this  
ChainChief

2d sprite collision with rotation

Recommended Posts

Im working on a 2d collision detection algorithm for my sprite engine. I've done this in the past with bounding rectangles, but that wont work with rotated sprites. For example, If the sun were in the center of the screen with the Earth rotating around it, my collision detection would always think the Earth is right above the sun because it does not account for rotation. My detection function accepts two custom jSprite classes, which hold information for all the transformations such as radians of rotation and rotation center point. How can I account for these transformations for detecting collisions?

Share this post


Link to post
Share on other sites
Quote:
Original post by ChainChief
Im working on a 2d collision detection algorithm for my sprite engine. I've done this in the past with bounding rectangles, but that wont work with rotated sprites. For example, If the sun were in the center of the screen with the Earth rotating around it, my collision detection would always think the Earth is right above the sun because it does not account for rotation. My detection function accepts two custom jSprite classes, which hold information for all the transformations such as radians of rotation and rotation center point. How can I account for these transformations for detecting collisions?


First, specify what language and API are you using otherwise giving code example is pretty much useless.
Anyway in DirectX the bounding rectangles aren't actually the best way to manage cause they have "problems" with rotations and such. I suggest switching to the use of bounding spheres and make them take account of the trasformation matrix you are applying to the object.

Share this post


Link to post
Share on other sites
I am using visual c++ 2008 with DirectX. The bounding spheres sounds like it would work well for my engine, but I am not sure how to set this up to take into account the transformations. Can someone send me a link to an explanation of this?

Share this post


Link to post
Share on other sites

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