Computer Graphics · Unit 4
2D Geometric Transformations
Exam-focused notes for 2D Geometric Transformations (Computer Graphics, BIT304): what the TU syllabus asks and how it has actually been tested, with 6 solved past questions from this unit.
2D Geometric Transformations in short
Geometric transformations move, turn, resize or distort objects. They are the base of animation, viewing and modeling, and they are written as matrices so a computer can apply them quickly.
What this unit covers
- Translation transformation
- Rotation transformation and matrices
- Scaling transformation and matrices
- Shearing transformation
- Homogeneous coordinates
- Composite transformations
- Successive rotations and angle addition
Scaling transformation and matrices
2082 · 10 marks
What is scaling in 3D graphics? Derive the scaling matrix for scaling along the X, Y, and Z axes. Apply the scaling transformation to a point (2,3,4) with scaling factors $S_x = 2$, $S_y = 3$, $S_z = 4$. [10]
Show solved answerHide answer
Scaling in 3D Graphics
Given
- Point: $P = (2, 3, 4)$
- Scaling factors: $S_x = 2$, $S_y = 3$, $S_z = 4$
Solution
Definition of Scaling
Scaling is a geometric transformation that alters the size of an object by multiplying each coordinate of its points by scaling factors along the coordinate axes. If all factors are equal, the scaling is uniform (shape preserved); if they differ, it is non-uniform (shape distorted). Scaling is performed relative to the origin unless a fixed point is specified.
Derivation of the Scaling Matrix
For a point $P(x, y, z)$, scaling produces $P'(x', y', z')$ such that each coordinate is multiplied by its scaling factor:
$$x' = S_x \cdot x, \qquad y' = S_y \cdot y, \qquad z' = S_z \cdot z$$
Writing this as a matrix relation on the 3-vector:
$$ \begin{bmatrix} x' \ y' \ z' \end{bmatrix}
\begin{bmatrix} S_x & 0 & 0 \ 0 & S_y & 0 \ 0 & 0 & S_z \end{bmatrix} \begin{bmatrix} x \ y \ z \end{bmatrix} $$
The off-diagonal entries are zero because each new coordinate depends only on the corresponding old coordinate. To combine scaling with translation using a single uniform representation, we use homogeneous coordinates, giving the $4 \times 4$ scaling matrix:
$$S = \begin{bmatrix} S_x & 0 & 0 & 0 \ 0 & S_y & 0 & 0 \ 0 & 0 & S_z & 0 \ 0 & 0 & 0 & 1 \end{bmatrix}$$
The bottom-right element is $1$ so that the homogeneous component ($w = 1$) is unchanged.
Application to the Point (2, 3, 4)
Step 1: Construct the scaling matrix
$$S = \begin{bmatrix} 2 & 0 & 0 & 0 \ 0 & 3 & 0 & 0 \ 0 & 0 & 4 & 0 \ 0 & 0 & 0 & 1 \end{bmatrix}$$
Step 2: Point in homogeneous coordinates
$$P = \begin{bmatrix} 2 \ 3 \ 4 \ 1 \end{bmatrix}$$
Step 3: Apply $P' = S \cdot P$
$$ P' = \begin{bmatrix} 2 & 0 & 0 & 0 \ 0 & 3 & 0 & 0 \ 0 & 0 & 4 & 0 \ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 2 \ 3 \ 4 \ 1 \end{bmatrix}
\begin{bmatrix} 2 \times 2 \ 3 \times 3 \ 4 \times 4 \ 1 \end{bmatrix}
\begin{bmatrix} 4 \ 9 \ 16 \ 1 \end{bmatrix} $$
Final Result
$$\boxed{P' = (4,\ 9,\ 16)}$$
The point $(2, 3, 4)$ scales to $(4, 9, 16)$ under factors $S_x = 2$, $S_y = 3$, $S_z = 4$.
Translation transformation
2082 · 5 marks
Explain the concept of translation transformation in 2D graphics. Discuss the effect of translation on objects. [5]
Rotation transformation and matrices
2081 · 10 marks
List the rotation matrix in clockwise direction with respect to x-axis, y-axis and z-axis. Rotate the object (0, 0, 0), (2, 3, 0), (5, 4, 0) about the rotation axis y = 4.[10]
Show solved answerHide answer
Rotation Matrices and Rotation About the Line y = 4
Given
Object vertices (2D points in xy-plane, z = 0):
- $P_1 = (0, 0, 0)$
- $P_2 = (2, 3, 0)$
- $P_3 = (5, 4, 0)$
Rotation axis: the line $y = 4$
Rotation angle: NOT specified in the question.
Note on missing data: The angle of rotation is not given. Since the points all lie in the $xy$-plane ($z = 0$) and the axis $y = 4$ is a line in that plane, this is a 2D rotation problem about a fixed point/line in the plane. The standard convention when no angle is stated in TU exams is a $180^\circ$ rotation (which keeps the figure in the same plane), but $90^\circ$ is also used. We solve for $180^\circ$ about the line $y = 4$ (the most natural in-plane interpretation), and also show the general method.
Solution
Part 1: Clockwise Rotation Matrices
A clockwise rotation by angle $\theta$ is the same as a counter-clockwise rotation by $-\theta$. Using $\cos(-\theta) = \cos\theta$ and $\sin(-\theta) = -\sin\theta$:
About X-axis: $$ R_x(\theta) = \begin{bmatrix} 1 & 0 & 0 \ 0 & \cos\theta & \sin\theta \ 0 & -\sin\theta & \cos\theta \end{bmatrix} $$
About Y-axis: $$ R_y(\theta) = \begin{bmatrix} \cos\theta & 0 & -\sin\theta \ 0 & 1 & 0 \ \sin\theta & 0 & \cos\theta \end{bmatrix} $$
About Z-axis (the relevant one for in-plane 2D rotation): $$ R_z(\theta) = \begin{bmatrix} \cos\theta & \sin\theta & 0 \ -\sin\theta & \cos\theta & 0 \ 0 & 0 & 1 \end{bmatrix} $$
Part 2: Rotating the object about the line y = 4
Since all points lie in the $z = 0$ plane and $y = 4$ is a horizontal line in that plane, the rotation is a 2D rotation about the pivot on that line, performed using $R_z$.
Sequence: Translate axis to origin, rotate about $z$, translate back.
$$T_1: (x, y) \to (x, y - 4), \qquad T_2: (x, y) \to (x, y + 4)$$
Step 1 - Translate by $(0, -4)$:
- $P_1' = (0, -4)$
- $P_2' = (2, -1)$
- $P_3' = (5, 0)$
Step 2 - Rotate by $\theta = 180^\circ$ (clockwise = same as CCW for $180^\circ$): With $\cos 180^\circ = -1$, $\sin 180^\circ = 0$: $$ R_z(180^\circ) = \begin{bmatrix} -1 & 0 \ 0 & -1 \end{bmatrix}, \quad (x, y) \to (-x, -y) $$
- $P_1'' = (0, 4)$
- $P_2'' = (-2, 1)$
- $P_3'' = (-5, 0)$
Step 3 - Translate back by $(0, +4)$:
- $P_1''' = (0, 8, 0)$
- $P_2''' = (-2, 5, 0)$
- $P_3''' = (-5, 4, 0)$
Final Rotated Points ($180^\circ$ about y = 4):
| Original | Rotated |
|---|---|
| $(0, 0, 0)$ | $(0, 8, 0)$ |
| $(2, 3, 0)$ | $(-2, 5, 0)$ |
| $(5, 4, 0)$ | $(-5, 4, 0)$ |
Why the In-Plane Reading Is Used
Interpreting $y = 4$ as an axis parallel to the x-axis and applying a 3D $90^\circ$ rotation about the y-axis ($R_y$) sends the points out of the plane, which is inconsistent because:
- A line $y = 4$ in a 2D figure is a pivot for an in-plane rotation about the z-axis, not the y-axis.
- The arithmetic also mislabels: rotating a point about the line $y=4$ should not change the $y$-coordinate of a point already at $y=4$ into $(0,4,5)$ moving in $z$; a physical rotation about a line in the plane keeps points in the plane for $180^\circ$.
Because the angle is not given, the numeric result is not unique. The working above uses $180^\circ$, the standard in-plane default; an out-of-plane $90^\circ$ rotation about the y axis would give different final coordinates.
Shearing transformation
2080 · 5 marks
Reflect a line segment having end points (9,3) and (12,10) about a line X = 7. Draw initial and final result graph as well. [5]
2079 · 5 marks
Write short notes on: a. Shearing and Scaling b. Line Clipping [5]
Successive rotations and angle addition
0 · 5 marks
Prove that successive rotation is equal to addition of angles. [5]
Make Unit 4 stick
Practice BIT304 with flashcards & quizzes