You are on page 1of 40

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M Gunathillake
(Student ID: 21204117)

H.R.P.P.M GUNATHILLAKE - 21204117

Graphic Application Development


Course Work 3

South Asian Institute of Technology and Medicine (SAITM)


Faculty of Design, Media & Management School of Applied Production & New Media Department
of New Media & Technologies.
1

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

Contents
Directed study 1 Points and Lines ....................................................................................................... 4
(a)

The Point Defined .................................................................................................................... 4

(b)

The Line Defined...................................................................................................................... 6

(c)

Properties of Line .................................................................................................................... 8

(d)

Applications in Collision Detection ....................................................................................... 10

Directed Study 2 Geometry Snippets................................................................................................ 11


(a)

Distance Between Points....................................................................................................... 11

(b)

Parabolas ............................................................................................................................... 12

(c ) Circles and Soheres .................................................................................................................. 15


(d) Application in Collision Detection ............................................................................................. 16
Directed study 3 Trigonometry Snippets .......................................................................................... 17
(a)

Degrees Versus Radians ........................................................................................................ 17

(b)

Trigonometric Functions ....................................................................................................... 19

Directed Study 4 Vector Operations ................................................................................................. 23


(a)

Vector Versus Scalar .............................................................................................................. 23

(b)

Polar Coordinates Versus Components ................................................................................ 24

(c)

Vector Addition and Subtraction.......................................................................................... 24

(d)

Scalar Multiplication.............................................................................................................. 25

(e)

Dot Product ........................................................................................................................... 26

(f)

Cross Product ........................................................................................................................ 26

Directed Study 5 Matrix Operations ................................................................................................. 27


(a)Equal Matrices ............................................................................................................................. 27
(b)Matrix Addition and Subtraction ................................................................................................. 27
(c)Scalar Multiplication .................................................................................................................... 28
(d)Matrix Multiplication ................................................................................................................... 29
(e)Transpose .................................................................................................................................... 30
Directed Study 6 Transformations .................................................................................................... 32
(a)Translation ................................................................................................................................... 32
(b)Scaling .......................................................................................................................................... 34
(c)Rotation ....................................................................................................................................... 35

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

Directed Study 7 Unit Conversions ................................................................................................... 37


(a)

The Metric System................................................................................................................. 37

(b) Converting Units Between Systems ........................................................................................... 37


Directed Study 8 Motion in one Dimension...................................................................................... 38
(a)

Speed and Velocity ................................................................................................................ 38

(b) Acceleration ................................................................................................................................ 38


(c) Equations of Motion ................................................................................................................... 38
Directed Study 9 Derivative Approach to Motion in One Dimension............................................... 39
(a)

Visualising Velocity and Derivative ....................................................................................... 39

(b) Visualising Acceleration and Second Derivative......................................................................... 39


Directed Study 10 Motion in Two and Three Dimensions ................................................................ 40
(a)

Using Vectors......................................................................................................................... 40

(b) Projectiles ................................................................................................................................... 40

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

Directed study 1 Points and Lines


(a) The Point Defined
1. Give the coordinates of the 2D points A through E shown in Figure 1.5.

Figure 1.5
A (2,1)
B (-1,3)
C (-3,0)
D (0,3)
E (3,-3)
F (-2,2)

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

2. Plot the following points on the grid provided in Figure 1.6

Figure 1.6

3. Give the coordinates of 3D point P shown in Figure 1.7

[2 ,1 ,4]

4. Give the coordinates of 3D point Q shown in Figure 1.8.

[1 ,1.5 ,2]

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

(b) The Line Defined


State whether the following equations are linear (that is if the complete solution is a line)
1.
2.
3.
4.

2x y = 5 - Linear
x + 5y = 0 - Linear
x = -1
- Linear
y + x squared = 5 - Non linear

Graph the following linear equations


1. x 2y = 0

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

2. -3x + y = 4

3. X = 1

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

(c) Properties of Line


Compare the slope between the following pairs of points:
1. (0,10) and (5,0)

m = 0 - 10
5-0

Slope (m) = -2

2. (3,5)and (1,9)

m=9-5
1-3

Slope(m) = -2

3. (2,-1)and (6,1)
m = 1 (-1)
6-2
Slope (m) = 1/2

4. (-2,5)and (1,4)
m=4-5
1- (-2)
Slope (m) = -1/3

5. (-3,5) and (-4,7/2)


m = 0 - 10
5-0
Slope (m) = 1.5

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

6. (9,8) and (9,-7)


m = 7/2 - 5
-4 (-3)
Slope (m) = 0

7. How are the lines from questions 1 and 2 related?


They have same slope, the lines are parallel
8. Describe what the line in question 6 looks like
It doesnt have a slope, vertical line

Find the slope of the following lines


9. 2x +3y =10
10. X 5y = 0
11. 2y = 8
12. x + y = -7

Slope (m) =
Slope (m) =
Slope (m) =
Slope (m) =

-2/3
1/5
0
-1

Find the equation of a line connection the following pairs of points:


13. (0,10) and (5,0)
14. (3,5) and (1,9)
15. (2,-1) and (6,1)
16. (-2,-5) and (1,4)

Slope (m) = -2 , Equation of the line , y = 2x+10


Slope (m) = -2 , Equation of the line , y = -2x + 11
Slope (m) = 1/2, Equation of the line , y = 1/2x - 2
Slope (m) = 3 , Equation of the line , y = 3x + 1

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

(d) Applications in Collision Detection


Give the slope and y-intercept for each equation and the number of solutions for the system
1. 2x + 6y = 6
-x + 3y = 6
Slope (m) = 1/3 , y-intercept } -2, 1
2. -6x + 12y = 12
-x + 2y = 2
Slope (m) = 1/2 , y-intercept } 12,1

3. -x + 2y = 4
-x + 2y + -4
Slope (m) = 1/2 , y-intercept } 2 , -2

Solve the following systems of linear equations using the linear combination method;
4. 4x + 6y = 16
X + 2y = 5
x=1,y=2
5. 3x + 8y = 24
x+y=3
x=0,y=3
Solve the following sys tem of linear equation using the substitution method;
6. 3x + 2y = 5
3x 2y = -1

(x= 2/3 , y = 3/2 )

7. 3x + y = 8
5x 2y = 9 (x = 25 , y = - 67)
10

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

Directed Study 2 Geometry Snippets


(a)

Distance Between Points

1. Find the length of side b, as shown in Figure 2.4

b = 4.24
2. A triangle is defined by the following vertices (30,75),(25,0)
and (-50,45) is it a right triangle?
Its not a right triangle.
3. Find the distance between points (30,80) and (150,130)
16900 = 130
4. Find the distance between points (20,50,10) and (100,120,40)
12200 = 110.45

5. Find the midpoint between points (30,80) and (150,130)


M = (90, 105)
6. Find the midpoint between points (20,50,10) and (100,120,40)
M =(60, 85, 25)

11

GRAPHIC APPLICATION DEVELOPMENT - CW3

(b)

H.R.P.P.M GUNATHILLAKE - 21204117

Parabolas

Give the vertex of the following parabolas


1. Y=10(x-4)^2 + 7
Vertex = (4,7)
2. X 2(y-5) + 1
Vertex = (5,1)
3. Y = (x+3)^2 + 2
Vertex = (-3,2)
4. X = -(3y)^2 12
X= -3y-12

5. Y = (x+1)^2
Vertex = (-1, 0)

12

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

Sketch the graph of the following parabolas


6. y = 10(x-1)^2 + 3
y = 10(x-1)2 + 3
x

y
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9

363
253
163
93
43
13
3
13
43
93
163
253
363
493
643
700
600
500
400
Series1

300
200
100
0
-10

-5

10

13

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

7. x = y^2 2
x = y2 2

y
23
14
7
2
-1
-2
-1
2
7
14
23
34
47
62
79

-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10
8
6
4
2

Series1

0
-20

-2

20

40

60

80

100

-4
-6

14

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

(c ) Circles and Soheres


Give the center and radius of the circles;
1. (x-30)^2 + (y-10)^2 = 400
Center = (30,10) , radius =20
2. (x+20)^2 + (y-90)^2 = 100
Center = (-20,90) , radius =10
3. (x+50)^2 + (y)^2 = 625
Center = (-50,-0) , radius =25

Find the equation of a circle that meets the following criteria


4. Center = (40, -25), radius = 30
Distance = 900
5. Center = (0,0), radius = 15

x + y = 15
6. Center = (-10,40), circle goes through the point (29,50)
(x+10)+(y-40)=1621

Give the center and the radius of the following spheres


7. (x -10)^2 + (y-30)^2 + (z-50)^2 = 1800
Center = (10,30,50) , radius = 40
8. X^2 + y^2 + y^2 = 100
Center = (0,0,0) , radius = 10
9. (x-50)^2 + y^2 +[z+40]^2 = 1
Center = (50,0,-40) , radius = 1
15

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

Find the equation of a sphere that meets the following criteria;


10. Center = (40,-25,30) , radius = 10
(x-40) + (y+25)+(z-30)=100
11. Center = (0,0,0) radius = 22
X + Y +Z = 484
12. Center = (10,0,-60), circle goes through the point (10,50,-30)

(X-10)+y+(Z+60)=3400

(d) Application in Collision Detection


1. Suppose you are coding the collision detection for a 2D baseball game, and you decide to
use bounding circles, in the current frame , one players bounding circle is defined by the
equation (x-70)^2 + (y-20)^2 = 1600, and the baseballs bouding circle is defined by the
equation (x-50)^2 + (y-60)^2 = 256. Have they collided yet? Yes, Collided.

2. Suppose you are coding the collision detection for a 3D football game, and you decide to use
bounding sphere is defined by the equation (x-50)^2 + y^2 + (z+20)^2 = 1600 and the
footballs bounding sphere is defined by the equation (x-60)^2 + (y-70)^2 + (z+50)^2 =
400.Have they collided yet? Yes, Collided.

16

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

Directed study 3 Trigonometry Snippets


(a)

Degrees Versus Radians


Draw the following angels in standard position
1. 120 = (90+30)

120

2. 270

270

17

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

3. -45

-45

Convert the following angels from degrees to radians;


4. 60

=/3

5. 270

=3/2

6. 45

=2/8

Convert the following angels from radians to degrees;


7. 135
8. 60
9. 72

18

GRAPHIC APPLICATION DEVELOPMENT - CW3

(b)

H.R.P.P.M GUNATHILLAKE - 21204117

Trigonometric Functions
Using your calculator, find the value of the following trigonometric functions;
1. Sin 45

0.70

2. Cos 125

-0.57

3. Tan - 35

-0.70

4. Find sin, cos and tan for the angle shown in Figure 3.14

Sin

=25/7

Cos

=25/24

Tan

=7/24

5. Find the degree measure of the angle in Figure 3.14


= sin (25/7)
6. Find cot -35

-0.998

7. Find csc 20

0.522

8. Find sec 45

0.066

19

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

9. y = 5sin3x

5
4
3
2
1
0
-1

Series1
0

100

200

300

400

500

600

-2
-3
-4
-5

10. y = 3cosx

4
3
2
1
0
-1

Series1
0

100

200

300

400

500

600

-2
-3
-4

20

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

11. y = cos4x

1.5
1
0.5
0

Series1
0

100

200

300

400

500

600

-0.5
-1
-1.5

12. y = 5sinx

6
4
2
0

Series1
0

100

200

300

400

-2
-4
-6

21

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

13. y =2cos(1/2x)

1.5
1
0.5
0

Series1
0

100

200

300

400

-0.5
-1
-1.5

14. y = 1/2sin(-2x)

0.6

0.4

0.2

Series1
0

200

400

600

800

-0.2

-0.4

-0.6

22

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

Directed Study 4 Vector Operations


(a) Vector Versus Scalar
1. Whats the different between a vector and a scalar quantity?
A scalar is just a number, sometimes called a magnitude without direction and a vector quantity
has both magnitude and direction.
2. Is -65 feet and example of a vector or a scalar? Its scalar
3. Is 35 seconds and example of a vector or a scalar? Scalar
4. If a runner on a straight track starts at the 5-ft.marker and stops at the 65-ft marker, whats
his displacement? 60ft
5. If a confused runner on a straight track starts at the 65-ft.
Marker and stops at the 5-ft, marker, whats his displacement? -60ft

6. Suppose you are playing Pong, and the paddle starts with a y-coordinate
Of 250 pixels.You move it down to the 100-pixel mark to hit the ball. Then you move down
300 pixel in anticipation of the next hit.As the ball approaches you realize you are a little off,
so you move down 20 pixels.whats the paddles overall displacement?
Displacement = +130px
7. What is the actual distance that the paddle in question 6 travels?
Actual distance = +470px

23

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

(b) Polar Coordinates Versus Components


1. Vector A is a velocity vector. Convert A = 25m/s @ 45 to Cartesian coordinates.
A=17.67i+ 17.67j
2. Convert vector B = 12i ^ + 5j^ to polar coordinates.
B = 13 units @ 42.96

3. Vector C is a force vector. Convert C=200N@60 to cartecian coordinates.


C=100 i+ 173.20 j
4. Convert vector D=8i^-6j^ to polar coordinates
D=10 units @ 76.39

(c) Vector Addition and Subtraction


1. Convert vector A=20ft @ 80 to Cartesian coordinates.
A=3.47 i + 19.69 j
2. Convert vector B=6i^+8j^ to polar coordinates
10 units@ 32.86
3. Using vectors A and B in the previous two questions , find the vector A+B
A + B = 9.47 i + 27.69 j

24

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

4. Using vectors A and B in the previous three questions, find the vector A-B
A B = -2.53 i + 11.69 j

5. Calculate F+G for vectors F = 2i^ - 4j^ - k^ and G = -5i^ + 3j^ + 6k^
F +G = -3 i - j + 5 k

6. Calculate F G for 3D vector F = 2i^ - 4j^ - k^ and G = -5i^ + 3j^ + 6k^


7 i -7 j -7 k

(d) Scalar Multiplication


1. Does Scalar multiplication affect a vectors magnitude or direction?
2. Calculate (-1/3)A if vector A=12m/s @ 43

magnitude

-4m/s @45

3. Calculate 6B if vector C = [24 10]

18 i - 6j

4. Normalise vector C = [24 10]

C=

5. Normalise vector D = [0.7 24]

D =

24/26

0.7/24.01

10/26

24/24.01

25

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

(e) Dot Product


1. Find A.B for vectors A = [-2 8] and B =[4 1]

2. Find C.D for vectors C = [-1 4 2] and D = [3 0 5]

3. Are vectors A and B in question 1 perpendicular?

Yes, if A.B=0, A is perpendicular to B

4. Find the angle between vectors C and D in question 2.

8.10

5. Suppose the camera in your game is currently sitting at (0,0)


and vector F = [4 9] represents the camera view.You know that the location of an object is
[3,-2].If the camera can see only 90 in each direction is the object in view?

(f) Cross Product


1. Find A x B for vectors A = [2 -3 5] and B = [-1 0 4]

[-12

-233]

2. Find the surface normal for vectors A and B in question 1 [0.459 0.88 0.11]
3. Find the angel between vectors A and B using he cross product you found in question 1.
=sin(25.37)

26

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

Directed Study 5 Matrix Operations


(a)Equal Matrices
1. Dimensions of matrix H = 3
2. Place of the entry in matrix H that has a 2 in it = (1,0)
3. Dimensions of matrix J = 20
4. Number 4
5. No, [ Dimensions of matrix K = 16 and Dimensions of matrix L = 9 ]
6. No, [Entries are not equal]

(b)Matrix Addition and Subtraction

1. C + D =

2. C D =

3.F + G =

-3

-1

-1

-6

-2

27

GRAPHIC APPLICATION DEVELOPMENT - CW3

4. F - G =

-2

-7

H.R.P.P.M GUNATHILLAKE - 21204117

-6

(c)Scalar Multiplication

1. -3A =

2. 1/2B =

-9

-15

-1

12

-30

-4

-1

-2

-8

3. If -1/4X = B 3A, find matrix X


12A 2B = X

12A 2B =

-36

52

64

-8

56

96

-44

28

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

(d)Matrix Multiplication
1.

2.

13

10

10

-5

3. Dimensions are not equal

4. Dimensions are not equal

-4
-4
5.

6.

36

-1

21

-1

15

29

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

(e)Transpose
1.

2.

3.

4.

5.

13

10

-4

-3

-2

10

-1

-1

-2

30

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

6.
1

-1

31

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

Directed Study 6 Transformations


(a)Translation
X

1. D (30, 80) =

70
=

60

New location of D = (70,60)


X
2. E(-50, 200) =
Y

-10
=

180

New location of E = (-10,180)

3. F(100,0)=

140
=

-20

New location of F= (140, -20)


4. G = (200, -300, -50) , H = (90, 0, -40), J = (-400, 50, -100)

X
Y
Z

250
=

-330
-50

new location of G: (250,-330,-50)

32

GRAPHIC APPLICATION DEVELOPMENT - CW3

140

-300

H.R.P.P.M GUNATHILLAKE - 21204117

=
Z

-40

new location of H: (140,-300,-40)

-350

-250
=

-100

new location of J: (-350,-250,-100)


5.
-300
L

50
1

-150
M

-60
1

-130
20
1

33

GRAPHIC APPLICATION DEVELOPMENT - CW3

6. G

-50

H.R.P.P.M GUNATHILLAKE - 21204117

140

-350

-330

-300

-250

-50

-30

-100

No, we dont get the same new location as question number 4.

(b)Scaling
1. A

-25

-5

-15

10

10

20

After uniformly scale 2D object in half; new location of A : (-25, 10, 1), new location of
B: (-5, 10, 1), new location of C : (-15, 20, 1)

2. A

-12.5

2.5

7.5

60

60

120

After making the objects tall and skinny by scaling in the X direction and 3 times in the Y
direction; new location of A: (-12.5, 60, 1), new location of B : (2.5, 60, 1),new location of C:
(7.5, 120, 1)

34

GRAPHIC APPLICATION DEVELOPMENT - CW3

3. D

H.R.P.P.M GUNATHILLAKE - 21204117

-500

-200

300

100

-1000

-200

-3000

After uniformly scale 3D object 10 times larger; new location of D: (0, 300, -1000,1), new location
of E: (-500, 100, -200, 1), new location of F: (-200, 0, -3000, 1).

(c)Rotation
-33.6
1. A

-215
1

68.8
40
1

-93
61
1

35

GRAPHIC APPLICATION DEVELOPMENT - CW3

2.

H.R.P.P.M GUNATHILLAKE - 21204117

-0.85
D

20
-49.5
1

-9.56
0
19.97
0

29.7
20
-0.51
1

3.

G=

H=

-50

J=

-20

28

28

210

14

56

-210

36

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

Directed Study 7 Unit Conversions


(a) The Metric System
1.

3x24x60 = 4320 minutes

2.

25.4 cm

3.

12 miles = 19312.1m

4.

362.102Km/Hr

5.

100.584 m/s

6.

(b) Converting Units Between Systems


1.

3500 cm

2.

0.035 km

3.

0.004567 km

4.

0.056 Kg

5.

3000g

37

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

Directed Study 8 Motion in one Dimension


(a) Speed and Velocity
1.

D=VT
65
X

2.

185px

3.

1.25m/s

15

1/60

= 16.25miles

4.

(b) Acceleration
1.

0.000310 m/s2

2.

990.36 m/s2

3.

3.725

(c) Equations of Motion


1.

1/20 = 0.05 m/s

2.

200s

3.

-8 m/s2

4.

100m

38

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

Directed Study 9 Derivative Approach to Motion in One Dimension


(a) Visualising Velocity and Derivative
1.

2.
3.
4.

3<=t<=6

-44

3<=t<=5

-28

3<=t<=4

-12

If h keeps getting closer and closer to 0, the instantaneous velocity gets closer and
closer to 2.
If h keeps getting closer and closer to 0, the instantaneous velocity gets closer and
closer to 90.
Derivative is simply 3

(b) Visualising Acceleration and Second Derivative


1.

1<=t<=5 ;
average acceleration 18.

2.

Instantaneous velocity gets closer and closer to 9.8.

3.

If h keeps getting closer and closer to 0, acceleration gets closer and closer to 34

39

GRAPHIC APPLICATION DEVELOPMENT - CW3

H.R.P.P.M GUNATHILLAKE - 21204117

Directed Study 10 Motion in Two and Three Dimensions


(a) Using Vectors
1.
2.

Displacement : [-175, -200]

3.

Displacement : [30,-30,-90]

4.

Average velocity : [-1.25 -10]

5.

Average velocity: [20 -30 -95]

(b) Projectiles
1.

40.5m

2.

2.76m

3.

18.96m

4.

1.44 m

40

You might also like