|
Hi all,
I've got a question concerning the implementation of the rotation*-methods in the Quaternion class. I understand the idea of rotating a point/vector P in 3D space around some axes with the aid of a quaternion q: simply represent P as a quaternion
p = (Px, Py, Pz, 0), the rotation by q=(sin(a/2)*qx, sin(a/2)*qy, sin(a/2)*qz, cos(a/2)) (where (qx, qy, qz) is the axis of rotation in 3D and a is the angle in radians) and compute q*p*conj(q) to obtain the rotated point as a quaternion (disregarding the w-part).
Until now I thought the rotate*-methods in the Quaternion class would be a convenient way to do exactly this. Yet it seems this is not the case. Take e.g. the implementation of the method rotateByAngleY(angle)
final float halfAngle = 0.5f * angle;
final float sin = FloatUtil.sin(halfAngle);
final float cos = FloatUtil.cos(halfAngle);
return set( x * cos - z * sin,
y * cos + w * sin,
x * sin + z * cos,
-y * sin + w * cos);
The result is not the rotation of a point (x, y, z) (represented by "this" quaternion (x, y, z, 0)) around "angle". It rather seems like "half" the conjugation step mentioned above, something like q*p (without the "*conj(q)"-part) but even then I computed it to be (x*cos+z*sin, y*cos+w*sin, -x*sin+z*cos, -y*sin+w*cos), notice the difference in signs). So really, what does this method actually compute, what is the interpretation of its result?
The documentation states "Rotate this quaternion around Y axis with the given angle in radians" -- but what does that mean exactly? I know there's a method "rotateVector", maybe it's doing what I expect, I haven't check yet. But what does "rotating a quaternion" mean?
|