<< Chapter < Page Chapter >> Page >

That concludes the explanation of the program named DotProd2D02 .

The program named DotProd3D01

To understand this program, you need to understand the material in the Kjell tutorial through Chapter 8 - Length, Orthogonality, and the Column Matrix Dot product .

The purpose of this program is to confirm proper operation of the ColMatrix3D.dot method. The program creates a GUI that allows the user to enter three values for each of a pair of ColMatrix3D objects along with a button labeled OK . When the user clicks the OK button, the dot product of the two ColMatrix3D objects is computed and displayed.

A screen shot of the output from the program named DotProd3D01

A screen shot of the output from the program named DotProd3D01 is shown in Figure 15 . (Compare Figure 15 with Figure 14 .)

Figure 15 A screen shot of the output from the program named DotProd3D01.

Missing image.

Very similar to a previous program

Except for the fact that this program calls the dot method on an object of the GM02.ColMatrix3D class instead calling the dot method on an object of the GM02.ColMatrix2D class, this program is essentially the same at the program named DotProd2D01 that I explained earlier. Therefore, you should have no trouble understanding this programwithout further explanation from me. A complete listing of this program is provided in Listing 11 .

That concludes the explanation of the program named DotProd3D01 .

The program named DotProd3D02

You need to understand the material in the Kjell tutorial through Chapter 10, Angle between 3D Vectors to understand this program.

Program output

A screen shot of the output of this program is shown in Figure 12 . This program allows the user to experiment with the dot product and the angle betweena pair of GM02.Vector3D objects. A GUI is provided that allows the user to enter six double values that define each of two GM02.Vector3D objects. The GUI also provides an OK button as well as two text fields used for display of the computed results.

In addition, the GUI provides a 3D drawing area. When the user clicks the OK button, the program draws the two vectors, (one in black and the other in magenta) , on the output screen with the tail of each vector located at the origin in 3D space. The program also displays the values ofthe dot product of the two vectors and the angle between the two vectors in degrees. (Compare the output of this 3D program in Figure 12 with the output from the 2D program in Figure 3 .)

Program code

A complete listing of this program is provided in Listing 12 . Almost all of the new and interesting code in this program is in the method named actionPerformed .

Very similar to a previous program

If you compare the method named actionPerformed in Listing 12 with the actionPerformed method for the program named DotProd2D02 in Listing 10 , you will see that they are very similar. One calls 2D methods in the game-math library while the other calls 3D methods in the same library.Therefore, you should have no difficulty understanding this program without further explanation from me.

That concludes the explanation of the program named DotProd3D02 .

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Game 2302 - mathematical applications for game development. OpenStax CNX. Jan 09, 2016 Download for free at https://legacy.cnx.org/content/col11450/1.33
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Game 2302 - mathematical applications for game development' conversation and receive update notifications?

Ask