|
-
Feb 23rd, 2007, 05:01 AM
#1
Thread Starter
Hyperactive Member
Collision Detection between rotated squares
How would you go about detecting collision between rotated squares?
I have googled it with little success.
-
Feb 23rd, 2007, 06:43 AM
#2
Hyperactive Member
Re: Collision Detection between rotated squares
Are they rotated randomly, or do they follow a position function?
-
Feb 23rd, 2007, 06:59 AM
#3
Frenzied Member
Re: Collision Detection between rotated squares
Test if their sides (which are lines) intersect eachother.
-
Feb 23rd, 2007, 10:26 AM
#4
Lively Member
Re: Collision Detection between rotated squares
A really easy (but not entirely accurate way) is to have a bounding sphere that approximates the square. Or you can do what jeroen said, test if the sides intersect. Other than that, you would have to do pixel perfect collision techniques. Just search on the forums or google it, there is lots of pages on it.
-
Feb 23rd, 2007, 11:10 AM
#5
Thread Starter
Hyperactive Member
Re: Collision Detection between rotated squares
Bounding sphere eh? Since my objects are not polygons (they are textures) it does not matter if the collisions are perfect.
Should I just test to see if the line drawn between centers of the objects is below a certain amount? e.g. the object's size
-
Feb 23rd, 2007, 11:40 AM
#6
Hyperactive Member
Re: Collision Detection between rotated squares
I was going to suggest a bouding box region as large as the squares can be when rotated (1.41*length).. To do the really cpu intensive polling, then if an intersection is 'possible' further analyze with trig/euclidean geometry..
-
Feb 24th, 2007, 07:11 PM
#7
Lively Member
Re: Collision Detection between rotated squares
 Originally Posted by singularis
Bounding sphere eh? Since my objects are not polygons (they are textures) it does not matter if the collisions are perfect.
Should I just test to see if the line drawn between centers of the objects is below a certain amount? e.g. the object's size
Basically yes. I meant to say bounding circles, lol, but it is the same in 2D as 3D, just with the Z dimension. Just see if the distance is less than the the sum of half of each square's side length (for example with squares of length 4 and 6 check if the distance between the centres is < root(2+3) [root(half of 4 + half of 6)]). If it is less than, then there is a collision.
You can fiddle around with what the value has to be less than to make the collisions "good", make it a constant times the sum of the radii of the squares.
Just a quick question, how many objects will be on screen at any time?
The one I suggested will work better with lots of objects on screen and is somewhat accurate where the one jeroen79 suggested is perfect for small numbers of objects and is accurate.
Last edited by fartman_900; Feb 24th, 2007 at 07:14 PM.
-
Feb 26th, 2007, 06:45 AM
#8
Thread Starter
Hyperactive Member
Re: Collision Detection between rotated squares
Yes I understand the difference between accuracy and speed . I am not a complete freshman.
There is going to be 100 or so objects on the screen.
-
Feb 26th, 2007, 02:38 PM
#9
Frenzied Member
Re: Collision Detection between rotated squares
What? You're only half a freshman?
-
Feb 26th, 2007, 03:16 PM
#10
Thread Starter
Hyperactive Member
Re: Collision Detection between rotated squares
-
Feb 26th, 2007, 08:10 PM
#11
Re: Collision Detection between rotated squares
I would set up a UDT which holds 4 points for each square. Then, if the points intersected, the collision had happened. Kind of a hack way to do it..
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Feb 27th, 2007, 07:46 PM
#12
Lively Member
Re: Collision Detection between rotated squares
Thats actually not a bad idea chem, you gave me an idea on a way to do it. You can think of the edges of the squares as planes, and find the normal and do a dot product to see if the value <= 0 (or >= 0 I forget) for a collision. It should be pretty fast and its precise.
-
Feb 28th, 2007, 10:41 AM
#13
Thread Starter
Hyperactive Member
Re: Collision Detection between rotated squares
And test the normal against what? the normal of the other square, would that not just tell us if they are facing the same way
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|