I simply duplicate each possible 3D rotation; one copy gets a "positive" quaternion, and the other copy gets a "negative" quaternion.
The resulting representation is equivalent to a 3-sphere in 4D hyper-space, it's orientable, and it completely avoids the problem of singularities and discontinuities. To multiply two quaternions, write each one as the sum of a scalar and a vector. The product of and is where. Please note: Quaternion-multiplication is NOT commutative. This is pretty obvious actually: As I explained, quaternions represent rotations and multiplying them "concatenates" the rotations. Now take your hand and hold it parallel to the floor so your hand points away from you.
Your hand should now be pointing to your right, with you looking at the back of your hand. Now invert the rotations: Rotate your hand around the y-axis so its facing right with the back of the hand facing upwards.
Now rotate around the x axis and your hand is pointing up, back of hand facing your left. See, the order in which you apply rotations matters. Ok, ok, you probably knew that To apply a quaternion-rotation to a vector, you need to multiply the vector by the quaternion and its conjugate. Quaternion vecQuat, resQuat; vecQuat.
In the following, I will present the methods necessary to convert all kind of rotation-representations to and from quaternions. I'll not show how to derive them because, well, who cares?
To rotate through an angle , about the axis unit vector , use:. Given a quaternion , the non-normalized rotation axis is simply , provided that an axis exists. For very small rotations, gets close to the zero vector, so when we compute the normalized rotation axis, the calculation may blow up. In particular, the identity rotation has , so the rotation axis is undefined.
To find the angle of rotation, note that and. As I said, multiplication is not commutative. The first rotates the existing quaternion around x looking up and down , the second rotates an upward-quaternion around the existing rotation. This is the behaviour you have in a 3D shooter. Try to change the order of rotations to see what happens. ModDB Wiki Explore.
Wiki Content. Explore Wikis Community Central. Register Don't have an account? Edit source History Talk 0. Cancel Save. We also show how to rotate objects forward and back using quaternions, and how to concatenate several rotation operations into a single quaternion.
The q 0 term is referred to as the "real" component, and the remaining three terms are the "imaginary" components. However, in this paper we will restrict ourselves to a subset of quaternions called rotation quaternions. Rotation quaternions are a mechanism for representing rotations in three dimensions, and can be used as an alternative to rotation matrices in 3D graphics and other applications. Using them requires no understanding of complex numbers.
0コメント