• Which way to turn an angle
    1 replies, posted
Okay. I have TargetAngle, and Angle in radians. How can I figure out weather to increment or decrement Angle so as to get to TargetAngle quickly? For example, lets say TargetAngle is 0 (3 o'clock), and Angle is at 6 o'clock (what ever that is in radians, maby 1/2pi?). I don't want to turn TargetAngle Counter-Clockwise, I want to turn it clockwise. For your information, incrementing is clockwise. Currently I have: [code]if(Math.abs((Angle+0.0001)-TargetAngle)>(Angle-0.0001)-TargetAngle){ Angle+=AngleVel; } else{ Angle-=AngleVel; } [/code] But it seems that when it gets to the target X axis, it just... goes around it.
Are you sure you didn't mean [code] if(Math.abs((Angle+0.0001)-TargetAngle) > Math.abs((Angle-0.0001)-TargetAngle)) { Angle+=AngleVel; } else{ Angle-=AngleVel; } [/code]
Sorry, you need to Log In to post a reply to this thread.