Game Development Reference
In-Depth Information
Rotation in the pitch is given by:
1
0
0
0
cos( p )
-sin( p )
P =
0
sin( p )
cos( p )
and bank rotation is given by:
cos( b )
sin( b )
0
B =
-sin( b )
cos( b )0
0
0
1
Combining columns with rows as follows is another form of matrix
multiplication:
a b c
A B C
Aa + Db + Gc
Ba + Eb + Hc
Ca + Fb + Ic
d e f
D E F
=
Bd + Ee + Hf
Cd + Fe + If
g h i
G H I
Ag + Dh + Gi
Bg + Eh + Hi
Cg + Fh + Ii
Using this method we can combine the H , P and B rotation matrices:
cos( h )cos( b ) - sin( h )sin( p )sin( b )
cos( h )sin( b ) + sin( h )sin( p )cos( b )
sin( h )cos( p )
HPB =
-cos( p )sin( p )
cos( p )cos( b )
-sin( p )
-sin( h )cos( b ) - cos( h )sin( p )sin( b )
-sin( h )sin( b ) + cos( h )sin( p )cos( b )
cos( h )cos( p )
Matrix multiplication is non-commutative, so HPB , HBP , PHB , PBH , BHP
and BPH all give different results.
Now, to translate the object vertices to world space we multiply all the
vertices as vectors by the rotation matrix above. Vector and matrix
multiplication is done in this way:
a b c
x
ax + by + cz
R =
def v =
y
Rv =
dx + ey + fz
g h i
z
gx + hy + iz
So the vertex ( x , y , z ) maps to the vertex ( ax + by + cz , dx + ey + fz , gx
+ hy + iz ). If the object also moves in the 3D world by T = ( tx , ty , tz ), then
the new position of the vertex should include this mapping. That is, the
vertex maps to Rv + T , giving the world location

Custom Search