# difference between two angles

This topic is 3718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm having some trouble trying to figure out how to find the distance between two angles from each other that range between -pi and pi. (ie, if one angle is -3.1 and the other +3.1, the distance should be ~0.08) Any advice would be appreciated.

##### Share on other sites
Is this what you mean?
Click the pictures to zoom in.

If it is, you can just rotate the angles so that one of them is on angle 0.
And you now get a right triangle.

You make the following calculations:

And now just use the values of the catheti to calculate the value of the hypothenuse.
sqrt((cos(angleA) - cos(angleB))^2 + sin(angleB)^2)
You can do it with angles bigger the 90 degrees too.

##### Share on other sites
I think he only wants this :

norm = |a1 - a2|
if Norm > pi:
Result = 2 * pi - norm
else
Result = norm

This works if the angles are between -pi and pi

1. 1
Rutin
25
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 20
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631762
• Total Posts
3002181
×