Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

If you intended to correct an error in the post then please contact us.

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

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this