Recently, in rewriting the scene management module of the game engine, I have been reviewing some knowledge about the four-dollar number and doing some simple notes here.
Four can be used to accurately describe the rotation of three-dimensional vector, and can effectively express the superposition of multiple rotation operations, so in the three-dimensional game engine scene management module, the four-dollar number has a very important significance.
This article for the stool a basket of original content, reproduced please indicate the source, thank you: http://www.cnblogs.com/dbylk/
first, the definition
form a = ai + bJ + Ck + D is a complex number called four, where i,J,k is an imaginary number (a primitive that is called a four-tuple), A, B, C, and D are real numbers.
second, the common nature
1. I2 = J2 = k2 =-1
2. ij = k JK = i ki = j
3. ij =–ji jk =–kj ki =-ki
4. II* = 1 I* =–i i.e. i* and i conjugate,J,K the same
5. Multiplication of four-tuple satisfies the binding law and distributive law, and does not satisfy the commutative law
6. The imaginary part of four yuan is regarded as three-dimensional vector, then the vector part of two four is αβ =-α,β +αxβ, so that four yuan a = α + d1,b = C7>β + D2, then
AB =-α•beta +αxbeta + d2α + D1Beta + d1d2 = (d1a2–c1b2 + B1C2 + a1d2) i
+ (c1a2 + d1b2–a1c2 + b1d2) J
+ (-b1a2 + a1b2 + d1c2 + c1d2) k
–a1a2–b1b2–c1c2 + d1d2
7. (AB) * = b*a*
8. Define the norm of four yuan A = ai + bJ + Ck + D for: | | a| | = A2 + b2 + C2 + d2 , modulo: | a| = sqrt (A2 + b2 + C2 + D2)
9. Define the inverse of the four-dollar a as: A-1 = */| | a| |
A-m = (A-1) m = (Am)-1
three, the use of four yuan to express the vector rotation
Assuming that the vector α revolves around the hinge e = (xe,ye,ze) Rotates the θ angle to get β, then:
β = uαu-1
which
u = e sin (θ/2) + cos (Θ/2)
u-1 = u* =- e sin (θ/2) + cos (Θ/2)
Therefore, we can use the four-tuple u = (x,y,z,w) to represent coordinate rotations, where:
x = sin (Θ/2) XE
y = sin (θ/2) ye
z = sin (θ/2) ze
w = cos (Θ/2)
iv. using matrices to represent coordinate rotations
Assuming that the axis of revolution is a = (Xa,ya,za) and the rotation angle is α, the rotation matrix is as follows:
five or four-dollar number and transformation of rotation matrix
According to the half-angle formula:
sinα= 2sin (Α/2) cos (Α/2)
cosα= Cos2 (Α/2)-sin2 (Α/2)
Cos2 (Α/2) = (1 +cosα)/2
Sin2 (Α/2) = (1-cosα)/2
A four-dollar conversion to a rotation matrix can be expressed as follows:
Four USD quaternion