Game Development Reference
In-Depth Information
Notice in particular that this is only defined in three dimensions. In two dimen-
sions there is no possible vector that is at right angles to two non-parallel vectors. In
higher dimensions (which I admit are not very useful for a games programmer), it is
also not defined in the same way.
2.1.9
T HE O RTHONORMAL B ASIS
In some cases we want to construct a triple of mutually orthogonal vectors, where
each vector is at right angles to the other two. Typically we want each of the three
vectors to be normalized.
Fortunately there is a simple algorithm using the vector product that we can fol-
low. This process starts with two non-parallel vectors. The first of these two will be in-
variant in direction; let's call this a : we cannot change its direction during the process,
but if it is not normalized, we will change its magnitude. The other vector, b ,maybe
changed if it is not already at right angles to the first. The third vector in the triple is
not given at all.
1. Find vector c by performing the cross product c
b .
2. If vector c has a zero magnitude, then give up: this means that a and b are parallel.
3. Now we need to make sure a and b are at right angles. We can do this by recalcu-
lating b based on a ,and c using the cross product: b
=
a
×
=
c
×
a (note the order).
a , b ,and
c .
This kind of triple of vectors is called an “orthonormal basis.” When we talk about
contact detection and contact resolution later in the topic, we will need this algorithm
several times.
Note that this algorithm is one in which it matters a great deal whether you are
working in a left- or right-handed coordinate system. The algorithm is designed for
right-handed systems. If you need a left-handed coordinate system, then you can sim-
ply change the order of the operands for both the cross products. This will give you a
left-handed orthonormal basis.
4. Normalize each of the vectors to give the output:
2.2
C ALCULUS
Calculus is a complex field with tendrils that reach into all areas of mathematics.
Strictly speaking calculus means any kind of formal mathematical system, but when
we talk about “the calculus,” we normally mean analysis: the study of the behavior of
functions. Real analysis is the most common topic of high school and undergraduate
calculus classes: the study of functions that operate on real numbers. We are interested
in vector analysis (usually widened to “matrix analysis,” of which vectors are just one
part). Even this subfield of a subfield is huge and contains many branches that have
filled countless topics on their own.
Fortunately for our purposes we are only interested in a very limited part of the
whole picture. We are interested in the way something changes over time: it might
Search Nedrilad ::




Custom Search