简体   繁体   中英

Euler angles change when using as_euler after from_euler

Could you explain what is happening here?

from scipy.spatial.transform import Rotation as R

euler_angles1 = [ -150, -180, -120 ]
rotation1 = R.from_euler("xyz", euler_angles1,degrees=True)
print(rotation1.as_euler("xyz",degrees=True))

euler_angles2 = [ -114, -83, -68 ]
rotation2 = R.from_euler("xyz", euler_angles2,degrees=True)
print(rotation2.as_euler("xyz",degrees=True))

Output:

array([ 30., 0., 60])
array([ -114., -83., -68.])

It seems that some angles get transformed to pi - angle while others remain as they were. Is there a rule? Is there an option to have the output euler angles remain the same as the input ones?

Scipy version: 1.5.4 Numpy version: 1.19.5

I tried the code above. My expectations were that the angles would be left unchanged after using from_euler and as_euler

They're equivalent. There's some intuition that there should probably be more than one way, one set of euler angles, to achieve the same rotation.

It's likely that scipy represents the rotation internally not as the euler angles you passed in but rather something more generic like a quaternion. So the euler angles are recalculated when you ask for them back and the values you receive are functionally equivalent.

> rot1 = R.from_euler("xyz", [-150, -180, -120], degrees=True)
> rot2 = R.from_euler("xyz", [30, 0, 60], degrees=True)
> rot1.as_matrix() @ [1, 2, 3]
array([0.29903811, 0.98205081, 3.59807621])

> rot2.as_matrix() @ [1, 2, 3]
array([0.29903811, 0.98205081, 3.59807621])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM