Game Development Reference
In-Depth Information
The alternative technique for 'multiplying' vectors is the cross product .
This method creates a further vector that is at right angles or orthogonal
to the two vectors used in the cross product. Unlike the dot product the
operation is not commutative. This simply means that
A
B does not necessarily equal B
A . Whereas A B = B A
×
×
The cross product of two 3D vectors is given by
A
×
B =[ Ay * Bz - Az * By , Az * Bx - Ax * Bz , Ax * By - Ay * Bx ]
This is easier to remember if we look at the pattern for calculating
determinants. Determinants are important scalar values associated with
square matrices. The determinant of a 1
×
1 matrix [ a ] is simply a . If A is
a 2
×
2 matrix then the determinant is given by
ab
cd
ab
cd
A =
,
det A =
That is the diagonal top left, bottom right minus top right, bottom left.
When extended to 3
3 matrices we have:
×
abc
def
ghi
ef
hi
df
gi
de
gh
A =
,
det A = a
- b
+ c
= a ( ei - fh )- b ( di - fg ) + c ( dh - eg )
Here we take the top row one at a time and multiply it by the determinant
of the remaining two rows, excluding the column used in the top row. The
only thing to bear in mind is that the middle term has a minus sign. If we
apply this to the vectors A and B we get
xyz
Ax Ay Az
Bx By Bz
Ay Az
By Bz
Ax Az
By Bz
Ax Ay
Bx By
A =
det A = x
- y
+ z
= x ( AyBz - AzBy )- y ( AxBz - AzBx ) + z ( AxBy - AyBx )
= x ( AyBz - AzBy ) + y ( AzBx - AxBz ) + z ( AxBy - AyBx )
The x , y and z terms are then found from the determinants of the matrix A .