Unity University Department of Computer Science Individual Assignment Course: Computer Graphics Code: Cosc3062
Unity University Department of Computer Science Individual Assignment Course: Computer Graphics Code: Cosc3062
Iteration Steps:
Iteration 0: x0 = 0 , y0 = 12 , d = -21
Iteration 1: x1 = 1 , y1 = 12 , d1 = -11
Iteration 2: x2 = 2 , y2 = 12 , d2 = -1
Iteration 3: x3 = 3 , y3 = 11 , d3 = 13
Iteration 4: x4 = 4 , y4 = 11 , d4 = -3
Iteration 5: x5 = 5 , y5 = 10 , d5 = 21
Iteration 6: x6 = 6 , y6 = 10 , d6 = 5
Iteration 7: x7 = 7, y7 = 9 , d7 = 33
Iteration 8: x8 = 8, y8 = 9 , d8 = 25
(15, 24) (16, 24) (17, 23) (18, 22) (19, 21) (20, 20) (21, 19) (22, 18) (23, 17) (24, 15)
(24, 14) (25, 13) (26, 12) (27, 11) (28, 9) (28, 8) (29, 7) (30, 6) (31, 5) (32, 3) (32, 2)
(33, 1) (34, 0) (34, -1) (35, -2) (36, -3) (37, -5) (37, -6) (38, -7) (39, -8) (40, -9) (41, -
11) (41, -12) (42, -13) (43, -15) (43, -16) (44, -17) (45, -18) (46, -19) (47, -21) (47, -22)
(48, -23) (49, -24) (49, -25) (50, -26) (51, -28) (51, -29) (52, -30) (53, -31) (53, -32) (54, -
33) (55, -34) (56, -36) (56, -37) (57, -38) (58, -39) (58, -40) (59, -41) (60, -42) (61, -43)
(62, -45) (62, -46) (63, -47) (64, -48) (64,
14
13
12
11
10
0
5 6 7 8 9 10 11 12 13
5. To translate the circle with center coordinates (1, 4) by a distance of 5 units towards
the X-axis and 1 unit towards the Y-axis, we use the translation equations:
X' x + xx
Y'= y + Ty
where Tx = 5 and Ty 1.
So, the new center coordinates of the circle after translation are (6, 5).
6. To apply the translation with a distance of 6 towards the X-axis and 3 towards the Y-
axis to a square with vertices at A (0, 3), B (3, 3), C (3, 0), and D (0, 0), we use the
translation equations:
X'=X + Tx
Y'=Y + Ty
where Tx = 6 and Ty = 3.
X'=0+6=6
Y'=3+3=6
X'=3+6=9
Y'=3+3=6
7. Given a triangle with corner coordinates (0, 0), (1, 0) and (1, 1).Rotate the triangle by 30 and
45 degree anticlockwise direction and find out the new coordinates
cos θ −sinθ
R(θ ) = [
sin θ cos θ ]
Rotating by 30o
√3 −1
o o
cos 30 −sin 30 2 2
o
R(30 ) = [ sin θ 30o cos θ 30 o ]=[ 1 √3 ]
2 2
√3 −1 √3 −1 √3−1
2 2 1 2 2 2
[ 1 √3 ] [ ] =[
1 1 √3 ]= [ √ 3+1 ]
2 2 2 2 2
√3−1 , √3+ 1
New Coordinates ( 2 2 )
Rotating by 45o
√2 −√ 2
o o
cos 30 −sin 30 2 2
o
R(45 ) = [ sin θ 30o cos θ 30 o ]=[ √2 √2 ]
2 2
New Coordinates (0 , √ 2)
8. Show that the composition of two rotations is additive by concatenating the matrix
representations for R (β1) and R (β2) to obtain R (β1). R (β2) = R (β1) + R (β2).
Let's denote R(β1) as R1 (β2) as R2
cos θ −sinθ
R(θ ) = [ sin θ cos θ ]
Now, for R1 and R2, we have:
cos (β 1)
R(1) = [ sin (β 1)
¿ ]
cos (β 2)
R(2) = [ sin (β 2)
¿ ]
Now, let's multiply these matrices:
cos (β 1) cos (β 2)
R1 ⋅ R2 = [ sin (β 1)
¿ ]⋅[ sin (β 2)
¿ ]
R1 ⋅ R2 = [ ¿]
cos (β 1+ β 2)
R1 ⋅ R2 = [ sin (β 1+ β 2)
¿ ]
This matrix represents the rotation R(β 1+ β 2), which shows that the composition of two
rotations is additive. Thus, R1⋅R2= R(β 1+ β 2),
9.
Shearing
Concept: Shearing distorts an object by tilting it along a specific axis. Imagine sliding
layers of the object sideways relative to each other.
2D Shearing: There are two types of shearing in 2D:
o X-shear: This slants the object along the x-axis. Points are shifted horizontally
based on their original y-coordinate.
o Y-shear: This slants the object along the y-axis. Points are shifted vertically
based on their original x-coordinate.
3D Shearing: Similar to 2D, 3D shearing can be applied along any of the three axes (x,
y, or z). Here, the concept remains the same, but we're dealing with changes in all three
coordinates.
Reflection
Concept: Reflection creates a mirror image of an object across a specific line (axis in 2D,
plane in 3D).
2D Reflection: Reflection can be performed across the x-axis, y-axis, or any line defined
by an equation. The object is flipped so corresponding points on either side of the
reflection line are mirrored.
3D Reflection: Reflection in 3D happens across a plane. We can reflect across the xy-
plane (mirroring on the ground), yz-plane (mirroring on a side wall), or any plane defined
by an equation.
Applications
Shearing: Used for creating parallelogram shapes, simulating wind effects on trees, or
animating object deformations.
Reflection: Creating realistic water surfaces, mirroring objects, or adding special effects
like portals.
By combining these transformations with others like rotation, scaling, and translation, we
achieve a wide range of effects in computer graphics and animation.
10.