# 1.3 Game 2302-0110: updating the game math library for graphics  (Page 20/20)

 Page 20 / 20

## 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.

## 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.

## 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.

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.

## 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.

## 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.

## 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.

-end-

where we get a research paper on Nano chemistry....?
nanopartical of organic/inorganic / physical chemistry , pdf / thesis / review
Ali
what are the products of Nano chemistry?
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
learn
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
learn
da
no nanotechnology is also a part of physics and maths it requires angle formulas and some pressure regarding concepts
Bhagvanji
hey
Giriraj
Preparation and Applications of Nanomaterial for Drug Delivery
revolt
da
Application of nanotechnology in medicine
what is variations in raman spectra for nanomaterials
ya I also want to know the raman spectra
Bhagvanji
I only see partial conversation and what's the question here!
what about nanotechnology for water purification
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
Nasa has use it in the 60's, copper as water purification in the moon travel.
Alexandre
nanocopper obvius
Alexandre
what is the stm
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?
what is a peer
What is meant by 'nano scale'?
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
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
Hafiz
what is Nano technology ?
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?
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
why we need to study biomolecules, molecular biology in nanotechnology?
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
why?
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
how did you get the value of 2000N.What calculations are needed to arrive at it
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!