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

  • Context: Undergrad 
  • Thread starter Thread starter Philosophaie
  • Start date Start date
  • Tags Tags
    Angle Degrees
Click For Summary
SUMMARY

The discussion focuses on converting an angle to fall within the range of -180 to 180 degrees using the modulo function. The formula provided is: angle = deg - 360 * floor(deg / 360) for angles outside this range. To adjust for the desired interval, the formula is modified by adding π, effectively translating the [0, 360] range to [-180, 180]. This method utilizes the properties of modulo arithmetic to achieve the desired angle normalization.

PREREQUISITES
  • Understanding of angle measurement in degrees
  • Familiarity with modulo arithmetic
  • Basic knowledge of mathematical functions and transformations
  • Experience with programming concepts for implementing formulas
NEXT STEPS
  • Research the properties of modulo operations in programming languages
  • Learn about angle normalization techniques in trigonometry
  • Explore the use of π in mathematical transformations
  • Investigate how to implement angle conversion functions in Python or JavaScript
USEFUL FOR

Mathematicians, software developers, and anyone working with angular measurements in graphics programming or physics simulations will benefit from this discussion.

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?
 
Mathematics news on Phys.org
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:

Similar threads

  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 21 ·
Replies
21
Views
4K
  • · Replies 3 ·
Replies
3
Views
1K