Can an angle be mirrored?

Started by
14 comments, last by Jiia 20 years, 1 month ago
New_Angle = 360 - Old_Angle;
Advertisement
Hmm how does atan2 work? It just does the 4 quadrants for you?

This is what I had to do to get the correct angle for my coordinate system:

angle_rad = atan2( DOUBLE(Vel.Y) , DOUBLE(Vel.X) );
angle_deg = -( (angle_rad * 180 / 3.141) - 90.0 );

Can that be right? Am I doing anything unnecessary?
Thanks again.

quote:Original post by Anonymous Poster
New_Angle = 360 - Old_Angle;

LMAO! Okay, I get it already

[edited by - Jiia on March 20, 2004 7:33:18 PM]
Just in case anyone is curious, I''m trying to get an arrow to point in it''s own path.
quote:Original post by Jiia
Hmm how does atan2 work? It just does the 4 quadrants for you?

Well, let's assume a coordinate system with x pointing right, y pointing up and angles growing counter-clockwise (zero degrees points right). Our mission is to determine the angle d between the x-axis and vector v = (v_x,v_y).

First we'll calculate the tangent of the angle:
tan d = v_y/v_x

That's the slope of the vector v. To get the angle we do:
d = arctan (tan d) = arctan (v_y / v_x)
(arcusfunctions have, by definition, the following property: f(arcf(x)) = x)

So, now we have an angle. But that's only the angle between the x-axis and a line parallel to the vector. The problem is that vectors also have direction.

To get the wanted angle we'll examine the signs of v_x and v_y.
- If they're both positive, the vector is in the 1st quadrant (up-right) and the angle is already correct
- v_x < 0 and v_y > 0 => 2nd quadrant. Now d is negative and you have to add 180 to it to get the angle you want
- Both negative => 3rd quadrant. d is positive and you add 180 again
- v_x > 0 and v_y < 0 => 4th quadrant. d is negative; you'll add 360.

All this will become clearer if you draw it on paper. And, of course, you can ask more here and I'll try to explain (I'm sure I've left things out and could probably have been much more clearer)

BTW, this is my first post in which I try to explain things. Actually, it's one of my first times I even try to explain something. I'll appreciate any (constructive) feedback.


[edited by - nonpop on March 21, 2004 4:20:27 PM]
I usually just use atan2(x,y); ... but it depends on your coordinate system (whether you want angle 0 to point at +y or +x and so on). Also it''s probably not necessary to convert angles into degrees since most math you do with them will require converting back to radians anyway.
Thanks for the detailed answer nonpop. It was very helpful.

And sorry again if I''m bringing this post way back from the dead.

This topic is closed to new replies.

Advertisement