<< Chapter < Page | Chapter >> Page > |
To assist you in this quest, I will present and explain modifications that were made to update the game-math library that you learned about in the previoustwo modules. In addition, I will present and explain three sample programs that illustrate the new features of the game-math library.
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.
Much of the code in the library remains unchanged. I explained that code in previous modules and I won't repeat that explanation in this module.Rather, in this module, I will concentrate on explaining the modifications that I made to the library.
A complete listing of the library program is provided in Listing 11 near the end of the module.
This update added the following new capabilities:
I will explain these updates in conjunction with the discussions of the programs that follow.
A complete listing of this program is provided in Listing 12 near the end of the module. I will explain the program in fragments. In selectingthe portions of the program that I will explain, I will skip over material that is very similar to code that I have previously explained.
The purpose of this program is to confirm the behavior of the equals methods of the GM2D03.ColMatrix , Point , and Vector classes.
Overridden equals method of the GM2D03.ColMatrix class
I will begin by explaining some of the equals methods in the updated GM2D03 game-math library.
The first fragment in Listing 1 shows the new equals method of the ColMatrix class.
Listing 1 . Overridden equals method of the GM2D03.ColMatrix class. |
---|
public boolean equals(Object obj){
if(obj instanceof GM2D03.ColMatrix&&Math.abs(((GM2D03.ColMatrix)obj).getData(0) -
getData(0))<= 0.00001&&Math.abs(((GM2D03.ColMatrix)obj).getData(1) -
getData(1))<= 0.00001){
return true;}else{
return false;}//end else}//end overridden equals method |
Notification Switch
Would you like to follow the 'Game 2302 - mathematical applications for game development' conversation and receive update notifications?