Between -180 and 180 degrees (convert a larger angle)

  • Level: Undergrad 
  • Thread starter Philosophaie
  • Start date
  • Tags Tags
    Angle Degrees
3 replies · 5K views · last reply
Philosophaie
Messages
456
Reaction score
0
I need a formula to put an angle between -180 and 180 and recycle if not in the range.

I can do it between 0 and 360:

angle = deg - 360 * floor(deg / 360)

just not between -180 and 180

Oh and what is the name of this function?
 
Take what you have and subtract 180.

Unless I'm not understanding what you're asking.
 
Philosophaie said:
I need a formula to put an angle between -180 and 180 and recycle if not in the range.

I can do it between 0 and 360:

angle = deg - 360 * floor(deg / 360)

just not between -180 and 180

Oh and what is the name of this function?
Function is modulo (mod). What you are asking for is mod 360.
 
EDIT Just add ## \pi ## to your formula and you will hit an angle in that interval. The interval [-180,180] is the translation of [0,360] by ##- \pi ##
 
Last edited: