20 views (last 30 days)

Hi

I need the angle between two rigid bodies. Each has a local right handed 3D coordinate system, while the z axis is pointing at the direction of the body (bones in my case).

So I want the angle between the z axes. I don't know the length of the vectors but what my software is giving me are the euler angles.

I used acos(cos(alpha)*cos(betha)) to get to the angle, which is fine but does not work for small angles.

Now i have a task where i expect the angle to go from 0 to + 60 and then again to 0 and -60. But what happens is that the angles does not get smaller then 5°/-5° and then makes a jump. I have read that the issue is how acos & cos is computed and that i should use atan2d(norm(cross(u,v)),dot(u,v)); But i don't know how to apply that since i dont have the vectors, I only got the angles. To get to the vectors will take me a lot more computation time and I really don't want to do that. Is there another way?

Thanks,

Simona

Jan
on 20 Aug 2019

There is no mathematical definition of "one angle between 2 3D-bodies". There is more than 1 degeree of freedom. An angle between 2 axes is possible. What is "alpha" and "beta" in acos(cos(alpha)*cos(betha)) ? Why do you assume, that the formula "does not work" for small angles? How are the Euler angles defined in your case?

The ACOS is instable near to 0, but you get deviations in the result by up to SQRT(EPS), about 1-e8. This is no explanation for your observation, that you get +-5 deg, while you expect +-60 deg.

Of course you need the vectors to determine the angle between them. There is no magic abbreviation to determine angles between axes based on Euler angles without computations.

If your Euler Angles are defined in the order XYZ, the Z-axis points to:

M.Z = [sin(E2), -cos(E2).*sin(E1), cos(E2).*cos(E1)];

where E1, E2, E3 are the corresponding Euler angles. For other orders, other formulas are needed. There are 12 different sets of orders, so please post, which one you are using.

After the two Z axes have been calculated, this is a stable method to determine the angle:

atan2(norm(cross(Z1,Z2)), dot(Z1,Z2))

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## Direct link to this comment

https://nl.mathworks.com/matlabcentral/answers/476817-from-euler-angle-to-angle-between-2-vectors#comment_737235

⋮## Direct link to this comment

https://nl.mathworks.com/matlabcentral/answers/476817-from-euler-angle-to-angle-between-2-vectors#comment_737235

Sign in to comment.