how to reverse an angle
Posted
by MissHalberd
on Stack Overflow
See other posts from Stack Overflow
or by MissHalberd
Published on 2010-06-15T10:51:11Z
Indexed on
2010/06/15
11:12 UTC
Read the original article
Hit count: 162
math
I am no mathematician, but I somehow got into game development as a hobby.
Having never studied anything beyond basic math, I have a lot of trouble figuring out how to reverse the angle of something, facing to the opposite direction, among the X axis. One image says more than 1000 words though (specially uneducated words): http://img156.imageshack.us/i/wihwin.png/
I basically want to reverse the direction of cannon objects adhered to a robot. When the robot changes from facing right to facing left, I do (180 - angle) as everyone suggested me, but it reverses the angle...literally, making the cannons aim up when they are aiming down. So, I need to do something else, but it escapes my knowledge.
Anyone would be so kind to help me with this? Oh, I use regular C by the way, in case there's something built-in specific to it.
To put it in other words, I work in 2D, so I want an angle that is facing right to face left. 0 being "totally to the right", 180 "left", 90 "up" and 270 "down". I want something that is aiming with an angle of 91 to turn into 89 when reversed, literally. There's no Z axis present.
EDIT: Thanks for the answers! Trying them out now. I'll post which one worked in a minute!
© Stack Overflow or respective owner