Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

11. Math Cheat Sheet > Surviving Graphics Math

Surviving Graphics Math

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.

Simple Vector Arithmetic

The following common operations are performed with vectors:

Reversing directionGLKVector3 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 scalingGLKVector3 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.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint