<< Chapter < Page Chapter >> Page >

Exercises

Exercise 1

Using Java and the game-math library named GM2D02 , or using a different programming environment of your choice, write a program that draws a horizontalline segment and a vertical line segment representing the x and y axes in a 2D Cartesian coordinate system as shown in Figure 2 .

Cause the origin of your reference frame be at the center of your drawing.

Cause the positive x direction be to the right.

Cause the positive y direction be either up or down according to your choice.

Cause the program to display your name in some manner.

Figure 2 Graphic output from Exercise 1.

Missing image.

Exercise 2

Using Java and the game-math library named GM2D02 , or using a different programming environment of your choice, write a program that draws x and y axes in a 2DCartesian coordinate system as shown in Figure 3 .

Cause the origin of your reference frame be at the center of your drawing.

Cause the positive x direction be to the right.

Cause the positive y direction be either up or down according to your choice.

Then draw small circles that represent the locations of points at the following coordinates in the reference frame as shown in Figure 3 .

  • x = -30, y = -40
  • x = 30, y = -40
  • x = 30, y = 40

Cause the program to display your name in some manner.

Figure 3 Graphic output from Exercise 2.

Missing image.

Exercise 3

Using Java and the game-math library named GM2D02 , or using a different programming environment of your choice, write a program that draws xand y axes in a 2D Cartesian coordinate system as shown in Figure 4 .

Cause the origin of your reference frame be at the center of your drawing.

Cause the positive x direction be to the right.

Cause the positive y direction be either up or down according to your choice.

Create six random values in the range from -128 to +127. Use those values as the x and ycoordinates for three points in the 2D reference frame. (The code fragment in Listing 29 shows how to generate random values in the required range in Java.)

Display the six values on a text screen labeled in such a way that it is possible to associate the valueswith the points as shown in Figure 5 .

Draw three small circles that represent the locations of the points.

Draw three line segments that connect the three points in pairs creating the shape of a triangle.

Cause the program to display your name in some manner.

Figure 4 Graphic output from Exercise 3.

Missing image.

Figure 5 . Text output from Exercise 3.
point0X: -55 point0Y: 17point1X: 9 point1Y: -37point2X: 14 point2Y: 62
Listing 29. Code for generating random values in Java.
//Define three randomly located points. Random generator = new Random(new Date().getTime());point0X = (byte)generator.nextInt(); point0Y = (byte)generator.nextInt();point1X = (byte)generator.nextInt(); point1Y = (byte)generator.nextInt();point2X = (byte)generator.nextInt(); point2Y = (byte)generator.nextInt();

Exercise 4

Using Java and the game-math library named GM2D02 , or using a different programming environment of your choice, write a program that draws three small circles that represent thelocations of points at the following coordinates in a 2D reference frame.

  • point0X = -30
  • point0Y = 0
  • point1X = 30
  • point1Y = 40
  • point2X = 30
  • point2Y = -40

Then draw three line segments that extend from edge-to-edge of your drawing and intersect the threepoints in pairs as shown in Figure 6 .

Cause the origin of your reference frame be at the center of your drawing.

Cause the positive x direction to be to the right.

Cause the positive y direction be either up or down according to your choice.

Cause the program to display your name in some manner.

Figure 6 Graphic output from Exercise 4.

Missing image.

Exercise 5

Using Java and the game-math library named GM2D02 , or using a different programming environment of your choice, write a program that draws 24 vectors tail-to-tail in alternatingcolors of red, green, and blue as shown in Figure 7 .

The first vector is red.

The length of each vector is 100 pixels.

The direction of the first vector is +7.5 degrees relative to the horizontal.

The direction of each successive vector is increased by 15 degrees.

For example, the directions of the first four vectors are:

  • 7.5
  • 22.5
  • 37.5
  • 52.5

Draw the symbol of your choice to identify the head of each vector.

Draw the axes for a Cartesian coordinate system in the reference frame.

Cause the positive x direction to be to the right.

Cause the positive y direction be either up or down according to your choice.

Cause positive angles to be either clockwise or counter-clockwise according to your choice.

Cause the program to display your name in some manner.

Figure 7 Graphic output from Exercise 5.

Missing image.

Exercise 6

Using Java and the game-math library named GM2D02 , or using a different programming environment of your choice, write a program that draws24 vectors tail-to-head in alternating colors of red, green, and blue as shown in Figure 8 .

The first vector is red.

The length of each vector is approximately 17 pixels.

Draw the symbol of your choice to identify the head of each vector.

Draw the axes for a Cartesian coordinate system in the reference frame.

Cause the positive x direction to be to the right.

Cause the positive y direction be either up or down according to your choice.

Cause positive angles to be either clockwise or counter-clockwise according to your choice.

Cause the program to display your name in some manner.

Figure 8 Graphic output from Exercise 6.

Missing image.

Exercise 7

Using Java and the game-math library named GM2D02 , or using a different programming environment of your choice, write a program that draws 24 vectors tail-to-head in alternatingcolors of red, green, and blue as shown in Figure 9 .

The first vector is red.

Begin with a length of 24 pixels for the first vector and reduce the length of each successive vector by one pixel.

Draw the symbol of your choice to identify the head of each vector.

Draw the axes for a Cartesian coordinate system in the reference frame.

Cause the positive x direction to be to the right.

Cause the positive y direction be either up or down according to your choice.

Cause positive angles to be either clockwise or counter-clockwise according to your choice.

Cause the program to display your name in some manner.

Figure 9 Graphic output from Exercise 7.

Missing image.

-end-

Questions & Answers

what is variations in raman spectra for nanomaterials
Jyoti Reply
I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
yes that's correct
Professor
I think
Professor
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
LITNING Reply
what is a peer
LITNING Reply
What is meant by 'nano scale'?
LITNING Reply
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
Daniel
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Good
Berger describes sociologists as concerned with
Mueller Reply
what is hormones?
Wellington
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?

Ask