<< Chapter < Page Chapter >> Page >
Keeping 2D and 3D classes separate:

All of the static top-level 2D classes in the existing game-math library were renamed with a suffix of 2D to distinguish them from the new top-level 3D classes. All of the new top-level 3D class names have a 3D suffix.

The ColMatrix2D and ColMatrix3D classes

From the very beginning, the game-math library has contained a statictop-level class named ColMatrix . In the updated version of the library, that class has been renamed ColMatrix2D .

Basically, the ColMatrix2D class provides a container for a pair of values of type double with appropriate methods for accessing those values. (I explained the original ColMatrix class in detail in an earlier module.) Similarly, the new ColMatrix3D class provides a container for three values of type double with appropriate methods for accessing those values.

Objects of the ColMatrix2D class are the fundamental building blocks for several of the other 2D classes in the library, and objects of the ColMatrix3D class are the fundamental building blocks for several of the other 3D classes in the library.

Behavior of the GM01.convert3Dto2D method

The convert3Dto2D method converts a ColMatrix3D object that represents a point in 3D space into a ColMatrix2D object that represents the projection of that 3D point onto a 2D plane .

The purpose of the method is to accept x, y, and z coordinate values describing a point in 3D space and totransform those values into a pair of coordinate values suitable for being displayed in two dimensions. The math that is implemented by this methodto do the projection is described on a web page that seems to move around a bit but the last time I checked, it was located at (External Link) If you don't find it there, try (External Link) In any event, a Google search should expose numerous pages that explain the math for projections of this type.

The transform equations

I won't attempt to justify or to explain the transform equations that are used to accomplish the projection in this module. Rather, I will simplyuse them as presented in the above resource. In the meantime, if you are interested in more information on the topic, you will find a wealth of information on 3D to 2Dprojections by performing a Google search for the topic.

The transform equations along with some of the assumptions that I made in the use of the equations are shown in Listing 2 .

Listing 2 . Transform equations for an oblique parallel projection from 3D to 2D.
The transform equations are: x2d = x3d + z3d * cos(theta)/tan(alpha)y2d = y3d + z3d * sin(theta)/tan(alpha); Let alpha = 45 degrees and theta = 30 degreesThen: cos(theta) = 0.866 sin(theta) = 0.5tan(alpha) = 1; Note that the signs in the above equations dependon the assumed directions of the angles as well as the assumed positive directions of the axes. Thesigns used in this method assume the following: Positive x is to the right.Positive y is up the screen. Positive z is protruding out the front of thescreen. The viewing position is above the x axis and to theright of the z-y plane.

Questions & Answers

how did the oxygen help a human being
Achol Reply
how did the nutrition help the plants
Achol Reply
Biology is a branch of Natural science which deals/About living Organism.
Ahmedin Reply
what is phylogeny
Odigie Reply
evolutionary history and relationship of an organism or group of organisms
AI-Robot
ok
Deng
what is biology
Hajah Reply
cell is the smallest unit of the humanity biologically
Abraham
what is biology
Victoria Reply
what is biology
Abraham
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
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