Anyways, if we do it this way, and we multiply the quaternion x, y, z, w with the quaternion X, Y, Z, W, the result would be

wX+xW+yZ+(-zY),

wY+(-xZ)+yW+zX,

wZ+xY+(-yZ)+zW,

wW-(xX+yY+zZ)

This is posted all over the place, and can easily be found by searching for "quaternion multiplication", but is just arbitrary enough that it does not get much support in hardware nor in many programming languages.

Also, some people like to use a slightly different expression that is equivalent to this only for unit quaternions. But given how modern computers are architected, I am dubious of the value of that approach.

Anyways, rotations can be represented with unit magnitude quaternions, and rotations can be combined by multiplying their quaternions, arranging them in right-to-left order (the first rotation must be furthest to the right).

But you can also use quaternion multiplication with non-unit quaternions to represent the rotation of points in space. A point in space has a w value of 0, and x, y and z are the coordinates of that point. If we call this quaternion P and our rotation quaternion R, the rotated point position is RPr. Here, r is the conjugate of R (in other words, using opengl's convention, -x, -y, -z, w where R would have been x, y, z, w).

So... why do we need 'r'? My informal take on this is that we first have to rotate space around in the opposite direction from R, then we move out to our point, then we rotate space back in the R direction. The result has our point P rotated by R.

## No comments:

## Post a Comment