Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
This chapter contains a crash course in 3D graphics math. If it makes your head spin, don’t worry too much. This section lists the most common 3D math operations that applications perform. Even without a deep understanding of the implementations, these recipes and techniques will solve most of the problems you might encounter.
The following common operations are performed with vectors:
• Reversing direction—GLKVector3 GLKVector3Negate(GLKVector3 vector) returns a new vector with the same length as vector but opposite direction. See GLKVector3Negate() used by the SceneCar class in Chapter 6, “Animation.”
• Length scaling—GLKVector3 GLKVector3MultiplyScalar(GLKVector3 vector, float value) scales the length of vector by value but does not change vector’s direction unless value is negative. GLKVector3MultiplyScalar(vector, -1.0) returns the same vector as GLKVector3Negate(vector). GLKVector3MultiplyScalar() is used in Chapter 4 to average surface normal vectors for smooth lighting simulation. The SceneCar sample class, the AGLKit sample classes, and the Utility sample classes also apply the function.