# difference between two angles

This topic is 3500 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

##### Share on other sites

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

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

• ### Forum Statistics

• Total Topics
628686
• Total Posts
2984237

• 16
• 13
• 13
• 10
• 10