Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

879770 Posts in 33005 Topics- by 24379 Members - Latest Member: alisiahl87

May 24, 2013, 10:32:52 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Collision detection : Rotation snapping
Pages: [1]
Print
Author Topic: Collision detection : Rotation snapping  (Read 614 times)
akademiks
Level 0
***


View Profile
« on: February 09, 2012, 02:00:15 PM »

Hi there,

Today i have an issue, i implemented a collision detection feature in a CAD application. When moving an object , i check if the new position create any collision with an object in the scene. If its the case then i calculate the distance before the collision to the collided object and i multiply it by the normalized direction vector to get the new collided position. This way the object snap to a collided body instead of traversing it.

Now i need to do the same but when the user perform a rotation on an object. The collision detection works but i don't really know how to calculate the "snapping" rotation delta. I have object A with X degrees of rotation that created a collision to object B. Now i need to revert the rotation of X degrees and find what X should be to snap on object B.

Any suggestions?
Thank you.
Logged
Danmark
Level 7
**



View Profile
« Reply #1 on: February 09, 2012, 05:40:50 PM »

You might get away with repeatedly rotating & testing collision in such a way as to converge on a good rotation. Failing that, I think finding the angle will be very involved, even just for convex objects.
Logged
akademiks
Level 0
***


View Profile
« Reply #2 on: February 09, 2012, 05:42:25 PM »

Yes, thx, actually this was my last option Smiley I only have convex objects
Logged
Flops
Level 0
**


View Profile
« Reply #3 on: February 10, 2012, 10:08:27 AM »

I'd try to calculate the angle between the two vectors: On each convex object you got one vector going through the point which collides and through the neighbor point. Angles which make sense would be 0°/180° (parallel) 90* and 45*. Maybe add 30° and 60°.
The math for this solution would be rather simple.
Logged
Flops
Level 0
**


View Profile
« Reply #4 on: February 10, 2012, 10:24:52 AM »

I did a short sketch, this is how I see your problem:


You would calculate alpha and look which angle it has approximately - then rotate it accordingly.
Logged
raigan
Level 4
****


View Profile
« Reply #5 on: February 10, 2012, 11:20:55 AM »

I think Redon and some others have published papers on true swept collision (where the rotation of the shape isn't approximated away, and you end up with complex paths for each vertex), e.g http://robotics.stanford.edu/~latombe/cs326/2004/class4/redon.pdf

I would personally just try a binary search as Veracity suggested, since this will be much much simpler.
Logged
akademiks
Level 0
***


View Profile
« Reply #6 on: February 10, 2012, 11:54:18 AM »

Flops, the problem is that the delta angle that caused the collision is not directly at the edge of the colliding object, its already traversing it.
I might end up recursively testing what angle i need using deltaAngle-- and test collisions with it
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic