- Try this same experiment but not at gimbal lock. For example, setting a = [0 80 1] will work as you expect. The closer the middle angle gets to 90 degrees, the more likely you'll hit the gimbal lock condition.
- Comparing Euler angles is a poor way to compare rotations for exactly reason you've found. If you want to compare two orientations use the quaternion dist method instead: dist(aa,cc). This will give you the angular distance between two orientations. Even at your gimbal lock example, you'll see the angular distance is 0.
Slerp gives wrong values when fed an euler matrix [0,90,0]
3 次查看(过去 30 天)
显示 更早的评论
Hello,
I am trying out the slerp function to create an interpolation function so i made a simple program to test it on different values :
a = [0,90,1];
b = [1,1,1];
rotationSequence = 'XYZ';
rotationType = 'frame';
% conversion to quaternions
aa = quaternion(a,'eulerd',rotationSequence,rotationType);
bb = quaternion(b,'eulerd',rotationSequence,rotationType);
% Apply Spherical linear interpolation
cc = slerp(aa, bb, 0);
% Conversion back to euler
c = eulerd(cc,rotationSequence,rotationType);
A 0 is supposed to give me back the exact same a. But I get weird values everytime I put 90° in the second element of my matrix.
If I put :
- a = [0,90,1] --> I get c = [1.0000,90,0]
- a = [0,90,2] --> I get c = [2.0000,90,0]
- a = [0,90,3] --> I get c = [3,90,0]
- a = [0,90,4] --> I get c = [4.0000,90,0]
- a = [0,90,5] --> I get c = [48.814074834290350,89.999999146226360,48.814074834290350]
- a = [1,90,1] --> I get c = [2.0000,90,0]
- a = [5,90,5] --> I get c = [10,90,0]
Changing the rotation sequence or the rotation type will give wrong results as well.
Can anyone help me understand why ?
0 个评论
采纳的回答
Brian Fanous
2022-6-28
What you are seeing is known as gimbal lock. You have set your a variable to a Euler angle singularity. Specifically in this case, because the Y rotation is set to 90 degrees, the X and Z rotations effectively do the same thing. You've lost a degree of freedom in your math. Wikipedia has a nice description.
Once you've converted from Euler angles to quaternions, you've lost the (notational) allocation of the non-Y rotation to either X or Z. Going back to Euler angles after slerp cannot rediscover where you had originally put the non-Y rotation.
Two things might help illustrated this:
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Math Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!