0

Everyone is trying to limit an angle into a 2*PI interval. Some uses [-PI, PI) while others use [0, 2*PI). Making such conversions sometimes lead to problems which come from using previous values of those angles such as taking derivative, calculating angular velocities etc. People always makes arrangements considering whether they did a roll-up or roll-down in the previous step.

However in my opinion this is useless. We should NOT need angles to be bounded into a 2*PI interval as they have different physical meanings. In mathematics 3*PI is not PI. They only give same results under some trigonometric functions but they are different angles indeed.

For example you need the real unbounded angles when you work with coils. I don't understand why people try to limit angles and track the turn count instead of using the exact unbounded angle.

I have searched many forums and have not come across a reasonable explanation.

What are the domains that I strictly have to limit an angle? In what areas limiting an angle makes the life better?

By the way I am aware of the natural bound coming from computer architecture which is way bigger than 2*PI.

Thanks

crbah
  • 338
  • 4
  • 12
  • 2
    A) This off-topic as it does not specifically address a software or Computer Science issue directly. B) This is too open-ended and inviting to discussion for the StackExchange network. – Zéychin Feb 15 '16 at 10:54
  • @Zéychin i dont think this is off-topic because wrapping angles on a 2*PI interval is a specific programming problem which is discussed here on several topics: or – crbah Feb 15 '16 at 11:17
  • Your post, as it is, makes no direct reference to a programming problem and so it is off-topic. – Zéychin Feb 16 '16 at 05:57

1 Answers1

1

First of all, I would like to state that angles are over-used. Sure, angles may be the best representation in some cases, but there are plenty scenarios in which other representations are better suited (e.g. direction vectors). And most of these alternative representations do not come with the difficulties of angles.

If, however, you find yourself in a scenario where angles should be used, there could be several reasons why you would want to limit the range of angles. But as you already wrote, it depends on the application.

If angles are used to represent a direction, then an angle of Pi is congruent to an angle of 3 Pi (resulting in the same direction). Working with a fixed range may have some benefits:

Floating point data types have higher precision near zero. If you use a 32 bit floating point number to represent a cumulative angle of let's say 1000 full rotations and a bit, you loose more than half the bits of the mantissa to represent the actual direction (disregarding full rotations). In this case, it might be desirable to store the full rotations in an integer (without any loss) and the fractional part in a floating point number (with less loss).

Comparing two angles (e.g. to calculate the angle between their according direction vectors) is easier if they are in the same range. Then, you only need to take care of wrapping at most one of them. If they are in an arbitrary range, you would have to compute how many times to wrap one of them.

If there are physical constraints (e.g. for joint angles of a skeleton), the reason for bounding the angles should be obvious.

Mapping angles to linear quantities (e.g. when you want to draw a diagram or mapping to colors) is easier if the angles are already in a range that just requires scaling and a constant offset.

In general, most reasons are pure questions of comfort. Not bounding angles could make the code a bit more wordy than it needed to be (and would probably even come with a very minor performance impact). If all these reasons do not apply to your scenario, you can leave your angles unbounded.

Nico Schertler
  • 32,049
  • 4
  • 39
  • 70