<< Chapter < Page Chapter >> Page >

Listing 12 . Source code for the program named ColMatrixEquals01.

/*ColMatrixEquals01.java Copyright 2008, R.G.BaldwinRevised 02/08/08 The purpose of this program is to confirm the behavior ofthe equals methods of the GM2D03.ColMatrix, Point, and Vector classes.Tested using JDK 1.6 under WinXP. *********************************************************/public class ColMatrixEquals01{ public static void main(String[]args){ GM2D03.ColMatrix matA =new GM2D03.ColMatrix(1.5,-2.6); GM2D03.ColMatrix matB =new GM2D03.ColMatrix(1.5,-2.6); GM2D03.ColMatrix matC =new GM2D03.ColMatrix(1.500001,-2.600001); GM2D03.ColMatrix matD =new GM2D03.ColMatrix(1.50001,-2.60001); System.out.println(matA.equals(matA));System.out.println(matA.equals(matB)); System.out.println(matA.equals(matC));System.out.println(matA.equals(matD));GM2D03.Point pointA = new GM2D03.Point( new GM2D03.ColMatrix(15.6,-10.11));GM2D03.Point pointB = new GM2D03.Point( new GM2D03.ColMatrix(15.6,-10.11));GM2D03.Point pointC = new GM2D03.Point( new GM2D03.ColMatrix(-15.6,10.11));System.out.println(/*Blank line*/); System.out.println(pointA.equals(pointA));System.out.println(pointA.equals(pointB)); System.out.println(pointA.equals(pointC));GM2D03.Vector vecA = new GM2D03.Vector(new GM2D03.ColMatrix(15.6,-10.11)); GM2D03.Vector vecB = new GM2D03.Vector(new GM2D03.ColMatrix(15.6,-10.11)); GM2D03.Vector vecC = new GM2D03.Vector(new GM2D03.ColMatrix(-15.6,10.11)); System.out.println(/*Blank line*/);System.out.println(vecA.equals(vecA)); System.out.println(vecA.equals(vecB));System.out.println(vecA.equals(vecC)); }//end main}//end ColMatrixEquals01 class
Listing 13 . Source code for the program named DisplacementVector01.
/*DisplacementVector01.java Copyright 2008, R.G.BaldwinRevised 02/08/08 The purpose of this program is to confirm the behavior ofthe getDisplacementVector method of the GM2D03.Point class.Tested using JDK 1.6 under WinXP. *********************************************************/public class DisplacementVector01{ public static void main(String[]args){ GM2D03.Point pointA = new GM2D03.Point(new GM2D03.ColMatrix(6.5,-9.7)); GM2D03.Point pointB = new GM2D03.Point(new GM2D03.ColMatrix(-6.0,9.0));System.out.println(pointA.getDisplacementVector( pointB));System.out.println(pointB.getDisplacementVector( pointA));}//end main }//end DisplacementVector01 class
Listing 14 . Source code for the program named ColMatrixAddSubtract01.
/*ColMatrixAddSubtract01.java Copyright 2008, R.G.BaldwinRevised 02/08/08 The purpose of this program is to confirm the behavior ofthe add and subtract methods of the GM2D03.ColMatrix class.Tested using JDK 1.6 under WinXP. *********************************************************/public class ColMatrixAddSubtract01{ public static void main(String[]args){GM2D03.ColMatrix matrixA = new GM2D03.ColMatrix(3.14,-6.01);GM2D03.ColMatrix matrixB = new GM2D03.ColMatrix(-14.0,-12.2);GM2D03.ColMatrix matrixC = matrixA.add(matrixB);GM2D03.ColMatrix matrixD = matrixC.subtract(matrixA); GM2D03.ColMatrix matrixE = matrixD.subtract(matrixB);System.out.println(matrixC);System.out.println(matrixD); System.out.println(matrixE);}//end main }//end class ColMatrixAddSubtract01

Exercises

Exercise 1

Using Java and the game-math library named GM2D03 , or using a different programming environment of your choice, write a program that createsfour column matrix objects using the following names and values:

  • matA = (1.5,-2.6)
  • matB = (1.5,-2.6)
  • matC = (8.5,-13.4)
  • matD = (5.5,-8.2)

Then use matrix addition and subtraction to compute and display the values of the following matrices:

  • matE = matA + matB
  • matF = matC - matD

Finally, test matE and matF for equality and display the result, replacing the question mark with either true or false..

Cause the program to display your name in some manner.

My version of the program produces the text output shown in Figure 4 , and you should use that as a display template.

Figure 4 Text output from Exercise 1.
Prof. Baldwin matE = 3.0,-5.2matF = 3.0,-5.200000000000001 matE equals matF: ?

Exercise 2

Using Java and the game-math library named GM2D03 , or using a different programming environment of your choice, write a program that createsand displays (in text form) three vectors having the names and values shown in Figure 5 .

Cause your program to test vecA for equality, first against vecB , and then against vecC , and display the results of the tests in place of the question marks shown in Figure 5 .

Figure 5 . Text output from Exercise 2.
Prof. Baldwin vecA = -1.5,2.6vecB = -1.5,2.6 vecC = 8.5,-13.4vecA equals vecB: ? vecA equals vecC: ?

Exercise 3

Using Java and the game-math library named GM2D03 , or using a different programming environment of your choice, write a program that createsand displays four column matrices having the names and values shown in Figure 6 .

Use the first two matrices to create a displacement vector named dispVecE and display its value in place of the question marks in Figure 6 .

Use the last two matrices to create another displacement vector named dispVecF and display its value in place of the question marks in Figure 6 .

Test dispVecE and dispVecF for equality and display the result of the test in place of the final question mark in Figure 6 .

Figure 6 . Text output from Exercise 3.
Prof. Baldwin matA = 1.5,-2.6matB = -1.5,2.6 dispVecE = ?,?matC = 8.5,-13.4 matD = 5.5,-8.2dispVecF = ?,? dispVecE equals dispVecF: ?

-end-

Questions & Answers

what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
cell is the building block of life.
Condoleezza Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

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