Direction vector from quaternion?

I have a quaternion representing the rotation of a three-dimensional character. I also have a line that should represent the new position of this character. This line position is defined by two 3D points.

This is the only data that I have, and I'm trying to call a method in a 3D package (Digital Rune), which takes 2 direction vectors and returns a quaternion representing the rotation needed to move the hand to a new position.

The problem is that I see some kind of odd behavior, as if the axes were mixed, and they usually do not behave. In addition, the Quaternion object (which is from a 3D package) representing the hand of three-dimensional guys has W, X, Y, and Z. Do X, Y, and Z represent the direction vector? Because this is what I need to call the function correctly. I used this along with my calculated direction vector from the endpoints of my line, but, as I said, it looks ridiculous.

If X, Y and Z are not a direction vector, how can I convert from a quaternion to two endpoints so that I can calculate the direction vector?

+7
source share
1 answer

In your context (and in most computer graphics contexts), a quaternion is used to represent rotation . You do not want to use X, Y, and Z directly; instead (as described in the above guide) you use it to generate a rotation matrix . Then you should use the rotation matrix, like any other 3D transformation matrix ; he will rotate the points around the origin, as described in the quaternion from which he came.

The quaternion X, Y and Z do represent the axis of rotation, but the quaternion also encodes the magnitude of the rotation not in the most direct way. If your package includes functions that return a quaternion, it should also include functions that turn its quaternions into rotation matrices; you should use a packaged function if possible (because it should be used by the same conventions as the method that created them).

After reading the quaternions and transformation matrices, you should carefully re-read the documentation for the function in question to make sure that you provide the correct arguments and make sure that you use the results in (it's easy enough to screw it even when you are familiar with math ...).

+7
source

All Articles