开发者

Quaternions still have gimbal lock

Instead of Euler angles I moved to Quaternions to represent and process the rotation of a cube in 3D. Although it would solve gimbal lock, I'm still experiencing this issue.

My code is:

// p is the point to be rotated
// angles is a Vector3D representing the rotation angles

var xaxis = new Vector3D(1, 0, 0);
var yaxis = new Vector3D(0, 1, 0);
var zaxis = new Vector3D(0, 0, 1);

p = rotate(p, xaxis, angles.x);
p = rotate(p, yaxis, angles.y);
p = rotate(p, zaxis, angles.z);

The rotate functions comes from http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#Pseudo-code_for_rotating_using_a_quaternion_in_3D_space (translated into JavaScript).

I guess the p开发者_Python百科roblem is due to the fact that I still use an order of axes (x y z) which is the main problem of gimbal lock.

How would one implement quaternion rotation in such a way that gimbal lock is solved?

Thanks in advance.


Quaternions are not susceptible to gimbal lock, so that's not your problem. If your x, y, and z angles are intended to represent something like Euler angles, the issue is more likely that you're defining xaxis, yaxis, and zaxis relative to the original coordinate system. But that won't give the expected results, because after the first rotation around xaxis, the Y and Z axes don't point in the original directions any more, yet the next two rotations are still referenced to the original coordinate system.


As you mention the gimbal lock issue arises anytime you do three consecutive rotations (such as Euler Angles) to get from an inertial coordinate frame to a body frame. This includes combining three successive quaternion rotations (through a operation called composition).

The reason why quaternions can overcome gimbal lock is that they can represent the transformation from the inertial coordinate frame to the body fixed frame in a single rotation. This is however imho the big disadvantage of quaternions - it is not physically intuitive to come up with a desired quaternion.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜