Hi folks. I posted a question about Atan2 and it's use a few days ago, but I don't think I explained enough about the problem.
I have two objects approaching each other, each has a random velocity vector. I first get the Normal of the collision angle from object 1, then calculate the tangent (90 degree rotation as all objects are circles), then calculate the angle between the approach of object 1 and the tangent. Everything to this point is perfect.
Then I use the following line of code:
- Radian = Math.Atan2(b.Y, b.X) - Math.Atan2(a.Y, a.X)
to obtain the angle of intersection of the two object's vectors. I believe this is correct, but only because I've picked it up from a forum somewhere on a similar subject, lord knows where.
I need this angle to then calculate a rotational deflection force of two colliding objects. I have the elastic bounce sorted, that's working perfectly. I'm not following the exact rules of physics here as I found that to be far too complicated, so I'm trying to 'fluff' an approximation, although the final calculation will include momentum and mass.
The problem I'm stumbling over is the result of the Atan2 calculation, I'm getting positive and negative values which I would expect depending if the collision were to the 'left or right', but I'm not totally understanding the output.
So, what exactly does the above Atan2 calculation give me? Does it return a true value between the two vectors, or against some axis? How is it affected by positive and negative input vectors? Do I need to be aware of quadrants in the returned data? Is an 'up/down' collision going to give a different result to a 'left/right' collision?
What I need is the angle between the 2 vectors without any interference, no matter of direction, with Vector A being treated as 0 degrees.
Any help would be greatly appreciated, I've been banging my head against this brick for days now!!
Many thanks.
(I hope this makes sense, I'm not a math person.)
I have two objects approaching each other, each has a random velocity vector. I first get the Normal of the collision angle from object 1, then calculate the tangent (90 degree rotation as all objects are circles), then calculate the angle between the approach of object 1 and the tangent. Everything to this point is perfect.
Then I use the following line of code:
- Radian = Math.Atan2(b.Y, b.X) - Math.Atan2(a.Y, a.X)
to obtain the angle of intersection of the two object's vectors. I believe this is correct, but only because I've picked it up from a forum somewhere on a similar subject, lord knows where.
I need this angle to then calculate a rotational deflection force of two colliding objects. I have the elastic bounce sorted, that's working perfectly. I'm not following the exact rules of physics here as I found that to be far too complicated, so I'm trying to 'fluff' an approximation, although the final calculation will include momentum and mass.
The problem I'm stumbling over is the result of the Atan2 calculation, I'm getting positive and negative values which I would expect depending if the collision were to the 'left or right', but I'm not totally understanding the output.
So, what exactly does the above Atan2 calculation give me? Does it return a true value between the two vectors, or against some axis? How is it affected by positive and negative input vectors? Do I need to be aware of quadrants in the returned data? Is an 'up/down' collision going to give a different result to a 'left/right' collision?
What I need is the angle between the 2 vectors without any interference, no matter of direction, with Vector A being treated as 0 degrees.
Any help would be greatly appreciated, I've been banging my head against this brick for days now!!
Many thanks.
(I hope this makes sense, I'm not a math person.)
Last edited by a moderator: