COMP3170 Assignment 2
Transformations
The purpose of this assignment is to test your knowledge of:
• 2D & 3D transformations: translation, rotation, scale, and shear
• Homogeneous coordinates & affine matrices
• Nested coordinate frames & the scene graph
Instructions
Throughout this assignment, all diagrams that you draw should be carefully drawn to scale using graph paper that you can download from the Internet. Sketches can be done by hand (using a ruler) and scanned (using a traditional scanner, a smartphone, or any other device that can legibly capture your sketches). You can also create your sketches using a suitable drawing program. Make sure there is always a clear distinction between the object and the axes in your diagrams. Marks will be deducted for poorly legible work.
You will be submitting your solution as a PDF, so ensure that you allow time for scanning your work to prepare your final PDF submission. Also, make sure that your scanned document is clearly legible: easy to read and clear for marking.
We will use the following notation for basic transformations. Please also use this notation in your answers. Incorrect notation may lose you marks.
2D Transformations
• 𝑇(𝑑𝑥, 𝑑𝑦) – translate by 𝑑𝑥 units in the x direction and 𝑑𝑦 units in the y direction.
• 𝑅(𝜃) – rotate anticlockwise by angle 𝜃.
• 𝑆(𝑠𝑥, 𝑠𝑦) – scale by 𝑠𝑥 in the x direction and 𝑠𝑦 in the y direction.
• 𝑆hh(h) – shear by h units horizontally.
• 𝑆h𝑣(𝑣) – shear by 𝑣 units vertically.
3D Transformations
• 𝑇(𝑑𝑥, 𝑑𝑦, 𝑑𝑧) – translate by 𝑑𝑥 units in the x direction, 𝑑𝑦 units in the y direction and 𝑑𝑧 units in the z direction.
• 𝑅𝑥(𝜃) – rotate about the x axis by angle 𝜃.
• 𝑅𝑦(𝜃) – rotate about the y axis by angle 𝜃.
• 𝑅𝑧(𝜃) – rotate about the z axis by angle 𝜃.
• 𝑆(𝑠𝑥, 𝑠𝑦, 𝑠𝑧) – scale by 𝑠𝑥 units in the x direction, 𝑠𝑦 units in the y direction and 𝑠𝑧 units
in the z direction.
Note: All points should be expressed as column vectors, i.e.:
(𝑦) for 2D points, and
(𝑦) for 3D points. 𝑧
This means that vector multiplication should be done on the right.
E.g., transforming point 𝑃 = (𝑦) by translation matrix 𝑇(𝑑𝑥, 𝑑𝑦) = [0 1 𝑑𝑦]
is represented by the equation:
𝑄 = 𝑇(𝑑𝑥, 𝑑𝑦)𝑃
𝑥 𝑄=[0 1 𝑑𝑦](𝑦)
𝑥 + 𝑑𝑥 𝑄 = (𝑦 + 𝑑𝑦)
1 0 𝑑𝑥 001
Question 1. Sketching Transformations in 2D [30 marks]
Figure 1 below shows a flag made up of four vertices with coordinates given in a model coordinate frame. Draw the result of applying each of the following transformations 𝑀 to the flag. Label the new coordinates for the four vertices in world coordinates. Show values to 1 decimal place. [5 marks each]
Figure 1: A triangular flag with vertices (0,0), (0,1), (0,2), (1,2)
E.g. For 𝑀 = 𝑇(−1,0) the resulting diagram would be:
Figure 2: The flag above after the transformation M=T(-1,0) is applied.
Note: These transformations do not stack. Apply each transformation to the original flag in Figure 1, not the previous question’s result.
a) 𝑀 = 𝑅(180°)
b) 𝑀 = 𝑆(1, 0.5)
c) 𝑀 = 𝑆(−1, 1)𝑇(1, 0)
d) 𝑀 = 𝑇(1, 0)𝑅(90°)
e) 𝑀 = 𝑅(45°)𝑇(0, −1)
f) 𝑀 = 𝑆(1, 0)𝑅(−45°)
Code Help, Add WeChat: cstutorcs
Question 2: 2D Homogeneous Matrices [30 Marks]
For each of the homogeneous matrices in (a)-(e) below:
i. Draw (to scale) the inner (model) and outer (world) coordinate frames for the
transformation represented by 𝑀, [2 marks]
ii. Write the decomposition of 𝑀 into two simple 2D transformations.
Answers should be specified in T, R, Sh, S order. [4 marks]
[6 Marks each]
For example, the matrix:
Can be drawn as:
201 𝑀=[0 1 2]
Figure 3: Example sketch of inner and outer coordinate frames for the matrix above.
And written as:
Note: Some questions have multiple correct answers. Any one correct answer is enough.
−1 0 −1 1 0 1 a)𝑀=[0 1 1] d)𝑀=[110]
001 001 1 −1 0 √3 1
b)𝑀=[110] 22
011 c) 𝑀=[1 0 1]
e)𝑀=−1 √3 1 222
𝑀 = 𝑇(1,2)𝑆(2,1)
Code Help
Question 3: 3D Transformations [40 Marks]
In the question below, give your answers as the product of simple transforms, e.g. 𝑀 = 𝑅𝑦(90°)𝑇(0,100,0)𝑅𝑥(45°)𝑆(2,1,1)
Transforms can be given in whatever order best suits the question.
Show your working. Incorrect answers with correct working may receive partial marks.
Do not calculate matrix values unless specifically requested (i.e. in part (g)).
Consider the following model aeroplane with origin and coordinate frame as indicated in Figure 4:
Figure 4: Model aeroplane, viewed from the top, side and rear.
a) Is this a right-handed or left-handed coordinate system? [2 marks]
Two copies of this model (P1 and P2) are placed in a scene, as shown in Figure 5 below.
• P1 is 200m north of the world’s origin point and 100m in the air. It is heading west.
• P2 is 300m west of the world’s origin point and 200m in the air. It is heading north-
Neither plane has been scaled.
Figure 5: A top-down view of a scene containing two planes P1 and P2.
b) What is the model matrix 𝑀𝑃1→𝑅𝑜𝑜𝑡 representing plane P1’s coordinate frame relative to the world, expressed as a product of simple 3D transformations
(T, Rx, Ry, Rz, S)? [3 marks]
c) What is the model matrix 𝑀𝑃2→𝑅𝑜𝑜𝑡 representing plane P2’s coordinate frame relative to the world, expressed as a product of simple 3D transformations
(T, Rx, Ry, Rz, S)? [3 marks]
Plane P2 flies forwards in a north-east direction for 200m without changing its altitude.
d) What is the new model matrix 𝑀𝑃2→𝑅𝑜𝑜𝑡 representing plane P2’s resulting coordinate frame relative to the world after this movement, expressed as a product of simple 3D transformations (T, Rx, Ry, Rz, S)? [3 marks]
A camera C is mounted on the right wing of the plane P1 positioned 20 metres directly to the right of the origin, as shown in Figure 6. The z-axis of the camera points to the right side of the plane.
Figure 6: Top and side views showing the camera C on the wing of plane P1.
e) Draw a scene graph including P1, P2 and C, with the world coordinate frame as the
root. [4 marks]
f) What is the matrix 𝑀𝐶→𝑃1 representing the camera C’s coordinate frame relative to the plane P1, expressed as a product of simple 3D transformations (T, Rx, Ry, Rz, S)? [3 marks]
The plane P1 pitches up 30 degrees, as shown in Figure 7:
Figure 7: Side view showing the plane P1 pitching up 30° (before and after).
g) What is the homogeneous matrix 𝑀 representing this 30° rotation in pitch? Write the matrix in full, using the trig functions sin() and cos().
You do not need to calculate a numerical result. [6 marks]
Taking the movements in (d) and (g) into account:
h) What is the model matrix 𝑀𝐶→𝑅𝑜𝑜𝑡 representing the camera C’s coordinate frame relative to the world, expressed as a product of simple 3D transformations (T, Rx, Ry, Rz, S)? [6 marks]
i) What is the model-view matrix 𝑀𝑃2→𝐶 representing the plane P2’s coordinate frame relative to the camera C, expressed as a product of simple 3D transformations (T, Rx, Ry, Rz, S)? [10 marks]
浙大学霸代写 加微信 cstutorcs