<< Chapter < Page | Chapter >> Page > |
This module will build on what you learned about the vector dot product in the earlier module titled GAME 2302-0145: Getting Started with the Vector Dot Product . In that module, you learned some of the theory behind the dot product. In this module, you will learn how to use the dot-productmethods of the game-math library to write several applications. I will present and explain the following four programs:
I will also provide exercises for you to complete on your own at the end of the module. The exercises will concentrate on the material that you have learnedin this module and previous modules.
The game-math library has not been modified since the previous module. Therefore, there is nothing new to discuss and explain insofar as the library isconcerned. For your convenience, a complete listing of the source code for the library is provided in Listing 9 near the end of the module.
A link to a zip file containing documentation for the library is provided in the earlier module titled GAME 2302-0145: Getting Started with the Vector Dot Product .
In order to understand this and the following programs, you need to understand the material in the Kjell tutorial through Chapter 10, Angle between 3D Vectors .
Game programming frequently requires the determination of angles of various types. The purpose of this program is to demonstrate how the dot product can beused to compute nine different angles of interest that a vector makes with various elements in 3Dspace.
Figure 3 shows a screen shot of the graphical user interface provided by this program.
Figure 3 - Screen shot of the output from the program named DotProd3D05.
Angles relative to the axes
First, the program computes and displays the angle between a user-specified vector (drawn in black in Figure 3 ) and each of the X, Y, and Z axes. These values are displayed with the labels Angle X , Angle Y , and Angle Z in Figure 3 .
Angles relative to the XY, YZ, and ZX planes
Then the program computes and displays the angle between the vector and each of the XY , YZ , and ZX planes. In this case, the program computes the smallest possible angle by projecting the vector onto the plane andthen computing the angle between the vector and its projection. These values are displayed with the labels Angle XY , Angle YZ , and Angle ZX .
Angles of projections relatives to the axes
Finally, the program computes and displays the angle between the projection of the vector on each of the three planes and one of the axes that defines eachplane. The angle between the projection and the other axis that defines the plane is 90 degrees minus the computed angle. Specifically the values that arecomputed and displayed are:
Notification Switch
Would you like to follow the 'Game 2302 - mathematical applications for game development' conversation and receive update notifications?