<< Chapter < Page Chapter >> Page >

Once the required vectors had been created in Listing 3 , there is nothing new in the code in Listing 4 . Therefore, no explanation of Listing 4 should be required beyond the comments embedded in the code.

The bottom line on the program named DotProd3D05

The bottom line is that because the methods in the game-math library named GM02 were designed to do most of the hard work, writing application programs such as DotProd3D05 using the game-math library is not difficult at all. You simply need to understand how to organize your code to accomplish the thingsthat you need to accomplish.

That concludes the explanation of the program named DotProd3D05 .

The program named DotProd3D06

This program demonstrates how the dot product can be used to find vectors that are perpendicular to a given vector.

An infinite number of possibilities

Recall that you learned in the previous module that there are an infinite number of vectors that are perpendicular to a given vector in 3D. This programcomputes and displays normalized and scaled versions of six somewhat unique vectors of the infinite setof vectors that are perpendicular to a user specified vector.

The graphic output

The screen output from this program is shown in Figure 4 .

Figure 4 - Six (magenta) vectors that are perpendicular to a given (black) vector.

Missing image.

Output on the command-line screen

In addition to the graphic output shown in Figure 4 , the program also displays the values of three of the perpendicular vectors on the command-linescreen along with the angle between the perpendicular vector and the user-specified vector. The angle should always be 90 degrees or very close to 90degrees if the program is working properly. The other three of the six perpendicular vectors are simply negated versions of the three for which thevalues are displayed.

Special case of one zero coordinate value

If the user specifies one of the coordinate values to be zero (or close to zero) , the program only computes and displays four of the possible vectors in order to avoid performing division by a near-zero value. In this case, theorientation of two of the vectors will overlay the orientation of the other two. Because the vectors are normalized to the same length and occupy the same space,you will only see two vectors instead of four. This is illustrated in Figure 5 where the value of the z-axis coordinate value was set to zero relative to thevalue used in Figure 4 .

Figure 5 - Screen output when one coordinate has a value of zero.

Missing image.

Special case of two coordinates with a value of zero

If the user specifies two of the coordinate values to be zero or close to zero, the program doesn't produce a valid result. Instead, it draws aperpendicular vector where all of the coordinate values are zero resulting in a magenta vector head at the origin. It also displays NaN (Not a Number) for the angle on the command line screen.

The graphical user interface

The GUI shown in Figure 4 is provided to allow the user to enter three double values that define a GM02.Vector3D object. The GUI also provides an OK button in addition to a 3D drawing area.

Questions & Answers

What is demand
TECK Reply
the amount of a good that buyers are willing and able to purchase
what is population
Amadou Reply
The people living within a political or geographical boundary.
what happens to price and quantity when demand curves shift to the right
Asha Reply
price level goes up. quantity demand increases
example- inferior goods
demand law
Its states that higher the price the of the commodity, and lower the quantity demanded
I am confused but quantity demand will increase.
No. That's the law of supply
what happens to price and quantity when supply curve shifts left?
Asha Reply
price level will increase
quantity demand will decrease
what is inflation
Pop Reply
inflation is a general and ongoing rise in the level of prices in an entire economy.
is the pasistance increase in the price of a country economy
how does inflation affects the economy of a country? what is deflation?
deflation can simply be define as the persistence decrease in price of a countrys economy
the revenge of malthus relates "revenge" with "commodity prices". collect data for 3 commodoties and check their price evolution
Jamshi Reply
what is elasticity
dubela Reply
Elasticity is an economics concept that measures responsiveness of one variable to changes in another variable.
Computer software represents
Mboledi Reply
पर्यावरण राज्यों में से किस राज्य में शिष्य शिक्षक अनुपात 30 से अधिक वाले विद्यालयों का प्रतिशत न्यूनतम होता है
plz Reply
Hey what are you trying to mean?
what is Asset
like a banana
demand is the process whereby consumers are willing and able to purchase a particular product at various price over a given period of time
Samuel Reply
The law of dinimish
Frank Reply
What is the law of dinimish
What is the law of dinimish
What is the law of dinimish
opportunity cost is to forgo something for another.
jackie Reply
what is financial market
Asheeru Reply
what is demand
Levinel Reply
Demand is an economic principle referring to a consumer's desire to purchase goods and services and willingness to pay a price for a specific good or service.
explain any three exceptions to the law of demand
Emma Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!

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?