Game Development Reference
In-Depth Information
F IGURE 9.2
The circle of orientation vectors.
where θ is the angular representation of orientation and θ is the vector representation.
I have assumed that zero orientation would see the object facing along the positive
X axis, and that orientation increases in the counterclockwise direction. This is simply
a matter of convention.
The vector form of orientation makes many (but not all) mathematical operations
easier to perform, with less special-case code and bounds-checking.
In moving to a two-dimensional representation we have doubled the number of
values representing our orientation. We have only one degree of freedom when decid-
ing which direction an object should face, but the representation of a vector has two
degrees of freedom. A degree of freedom is some quantity that we could change inde-
pendent of others. A 3D position has three degrees of freedom, for example, because
we can move it in any of three directions without altering its position in the other two.
Calculating the number of degrees of freedom is an important tool for understanding
rotations in 3D.
Having this extra degree of freedom means that we could end up with a vector that
doesn't represent an orientation. In fact most vectors will not match equation 9.1. To
guarantee that our vector represents an orientation, we need to remove some of its
freedom. We do this by forcing the vector to have a magnitude of 1. Any vector with
a magnitude of 1 will match equation 9.1, and we'll be able to find its corresponding
angle.
There's a geometric way of looking at this constraint. If we draw a point at the end
ofallpossiblevectorswithamagnitudeof1,wegetacircle,asshowninfigure9.2.We
could say that a vector orientation correctly represents an orientation if it lies on this
circle. If we find a vector that is supposed to represent an orientation but is slightly
off (because of numerical errors in some calculation), we can fix it by bringing it onto
Search Nedrilad ::




Custom Search