<< Chapter < Page Chapter >> Page >
Listing 12 . Draw six lines connecting the vertices of the hexagon.
GM2D02.Line line01 = new GM2D02.Line(point0,point1); GM2D02.Line line12 = new GM2D02.Line(point1,point2);GM2D02.Line line23 = new GM2D02.Line(point2,point3); GM2D02.Line line34 = new GM2D02.Line(point3,point4);GM2D02.Line line45 = new GM2D02.Line(point4,point5); GM2D02.Line line50 = new GM2D02.Line(point5,point0);//Now draw a visual manifestation of each line // on g2Da.line01.draw(g2Da); line12.draw(g2Da);line23.draw(g2Da); line34.draw(g2Da);line45.draw(g2Da); line50.draw(g2Da);

Then Listing 12 calls the draw method belonging to the GM2D02.Line class six times in succession to cause visible lines to be rendered on the specified off-screen image. You can see those sixlines in the left image in Figure 1 .

That completes the drawing that is performed on the off-screen image shown in the left image in Figure 1 . Next I will explain the drawing that is performed on the off-screen image that is shown as the right image in Figure 1 .

Instantiate three objects of type GM2D02.Vector

According to Kjell, "A vector is a geometrical object that has two properties: length and direction ." He also tells us, "A vector does not have a position."

The right image in Figure 1 shows visual manifestations of three differentobjects of the GM2D02.Vector class. One vector is represented as a red line with a small red circle at its head. A second vector isrepresented as a blue line with a small blue circle at its head. The third vector is shown in three different positions represented by green lines withsmall green circles at their heads.

Listing 13 instantiates three objects of the GM2D02.Vector class, which are visually represented by the red, green, and blue lines in Figure 1 . References to these three objects are saved in the variables named vecA , vecB , and vecC in Listing 13 .

Listing 13 . Instantiate three objects of type GM2D02.Vector.
GM2D02.Vector vecA = new GM2D02.Vector( new GM2D02.ColMatrix(50,100));GM2D02.Vector vecB = new GM2D02.Vector( new GM2D02.ColMatrix(75,25));GM2D02.Vector vecC = new GM2D02.Vector( new GM2D02.ColMatrix(125,125));

Note that each vector is described by two values in a GM2D02.ColMatrix object.

Call the draw method to draw the vector

Listing 14 begins by setting the drawing color to red for the off-screen image on which the visual manifestation of the first Vector object will be drawn. Then Listing 14 calls the draw method of the GM2D02.Vector class to cause the object referred to by vecA to be represented as a (red) line with its tail at the origin. (Unlike the image on the left side of Figure 1 , the origin for the image on the right was not translated to the center.)

Listing 14 . Call the draw method to draw the vector.
g2Db.setColor(Color.RED);vecA.draw(g2Db,new GM2D02.Point( new GM2D02.ColMatrix(0,0)));

Note that two parameter are passed to the draw method in Listing 14:

  • A reference to the off-screen graphics context on which the visual manifestation of the vector will be drawn.
  • A new object of the class GM2D02.Point that will be used to determine the position on the off-screen image in which the visualmanifestation will appear.

Questions & Answers

what is microbiology
Agebe Reply
What is a cell
Odelana Reply
what is cell
Mohammed
how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
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