   Can an angle be mirrored?
  This is a really simple question. I'd like to know if an angle can be mirrored right-left without a switch-case statement. The angle is limited to 45 degree increments.if = new45 = 31590 = 270135 = 225225 = 135270 = 90315 = 450 = 0180 = 180Thanks for any help! [edited by - Jiia on March 20, 2004 3:06:52 PM]
  new_angle = 360 - old_angle?   [edited by - Muzzafarath on March 20, 2004 3:09:53 PM];  LMAO! Thanks I appreciate it. ;  Can I ask another simple question that will make me further look like an idiot?How can I use two velocities (x & y) to determine a 0-360 angle? The velocities can be positive and negative, and can be any range.If I figure it out before anyone answers, I''ll reply again.Thanks again! ;  Finding the angle? If I understand you correctly, the below code should work, I'm not entirely sure, but in theory I think it will.float tangent = y / x;float angle = 1 / tangent;  That should give you the angle. Just a warning, this code only works with first quadrant angles. If you want other quadrants, you will have to write some testing and so forth.   (Stolen from Programmer One)UNIX is an operating system, OS/2 is half an operating system, Windows is a shell, and DOS is a boot partition virus   [edited by - Dragon88 on March 20, 2004 6:09:34 PM] [edited by - Dragon88 on March 20, 2004 6:10:17 PM];quote:Original post by Jiia  Can I ask another simple question that will make me further look like an idiot?How can I use two velocities (x & y) to determine a 0-360 angle? The velocities can be positive and negative, and can be any range.If I figure it out before anyone answers, I''ll reply again.Thanks again!  I assume you mean that x and y are the components of one velocity.If so, the angle would be arctan(y/x).Here''s why.Given a triangle where the hypotenuse is the actual velocity, and each leg is a component of that velocity (x and y), the angle formed between the resultant velocity and the x-axis would be the angle you''re looking for.The tangent of that angle is equal to the opposite side (y) over the adjacent side (x). Therefore, the angle is equal to the arctangent of the ratio y/x. ;quote:Original post by Dragon88  float tangent = y / x;float angle = 1 / tangent;  ...won''t work. It should be (for example)float angle_rad = atan2(y,x);float angle_deg = angle_rad*180/PI;  The result is in range -180...180.There''s also a function, atan(), which will take the tangent as parameter and return a value in range -PI/2...PI/2. In this case you have to determine the quadrant yourself.;  Subtract it from 360...   The Untitled RPG - |||||||||| 40%Free Music for your games;  This seems to return an angle of -78 with XVel=40, YVel=-40:angle = (LONG) atan(DOUBLE(Vel.Y)/DOUBLE(Vel.X)) * 100.0;Did I screw something up? Is up negative or positive? What is the value range of atan?Thanks for all of the help, much appreciated!EDIT: I totally forgot to mention that my straight-up angle is 0. Straight down is 180. But that could be easily fixed by adding or subtracting. I also need to watch out for X-velocity to be zero, correct? Should I just make a special case and set 0 and 180 manually?   [edited by - Jiia on March 20, 2004 6:40:59 PM];  atan() returns the angle in radians. To convert it to degrees, you doangle_deg = angle_rad*180/PI;  EDIT: Typo. BTW if you'll stay with atan() instead of atan2(), you'll have to determine the quadrant of the angle yourself (basically you check whether vel_x and/or vel_y are positive or negative and such; drawing things on paper will help).   [edited by - nonpop on March 20, 2004 6:55:10 PM]