4 2d Geometric Transformations

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.

2D Geometric Transformations: notes

Translation transformation

Translation moves every point of an object by the same distance in a straight line. A point $P(x,y)$ moves to $P'(x',y')$ with translation distances $t_x$ and $t_y$:

$$\begin{aligned} x' &= x + t_x \ y' &= y + t_y \end{aligned}$$

In matrix form, $P' = P + T$ where $T = \begin{bmatrix} t_x \ t_y \end{bmatrix}$.

Effects on the object:

  • Shape, size and orientation do not change. It is a rigid-body transformation.
  • Every point moves by the same vector, so lines stay parallel and lengths stay equal.
  • To move a polygon, translate only its vertices and redraw the lines.

Example: translate the point $(2,3)$ by $(t_x,t_y) = (3,-1)$. Result: $(5,2)$. A triangle $(1,1), (4,1), (2,3)$ with the same shift becomes $(4,0), (7,0), (5,2)$.

Rotation transformation and matrices

Rotation turns an object about a pivot point by an angle $\theta$. A positive angle means counterclockwise. About the origin:

$$\begin{aligned} x' &= x\cos\theta - y\sin\theta \ y' &= x\sin\theta + y\cos\theta \end{aligned}$$

$$R(\theta) = \begin{bmatrix} \cos\theta & -\sin\theta \ \sin\theta & \cos\theta \end{bmatrix}$$

For a clockwise rotation, replace $\theta$ by $-\theta$:

$$R(-\theta) = \begin{bmatrix} \cos\theta & \sin\theta \ -\sin\theta & \cos\theta \end{bmatrix}$$

Example: rotate $(4,2)$ by $90^\circ$ counterclockwise: $x' = 4(0) - 2(1) = -2$ and $y' = 4(1) + 2(0) = 4$. The result is $(-2,4)$.

Rotation about a pivot point $(x_r,y_r)$: translate the pivot to the origin, rotate, and translate back.

$$\begin{aligned} x' &= x_r + (x - x_r)\cos\theta - (y - y_r)\sin\theta \ y' &= y_r + (x - x_r)\sin\theta + (y - y_r)\cos\theta \end{aligned}$$

Example: rotate triangle $A(5,7)$, $B(12,85)$, $C(5,3)$ by $30^\circ$ counterclockwise about $C(5,3)$. Here $\cos 30^\circ = 0.866$ and $\sin 30^\circ = 0.5$.

For $A$: $x - x_r = 0$, $y - y_r = 4$.

$$\begin{aligned} x' &= 5 + 0 - 4(0.5) = 3 \ y' &= 3 + 0 + 4(0.866) = 6.46 \end{aligned}$$

For $B$: $x - x_r = 7$, $y - y_r = 82$.

$$\begin{aligned} x' &= 5 + 7(0.866) - 82(0.5) = -29.94 \ y' &= 3 + 7(0.5) + 82(0.866) = 77.51 \end{aligned}$$

$C$ is the pivot, so it stays at $(5,3)$. The new triangle is $A'(3, 6.46)$, $B'(-29.94, 77.51)$, $C'(5,3)$.

3D rotation is done about an axis. Counterclockwise about the z-axis uses the same 2D matrix with $z' = z$. Clockwise matrices for the three axes:

$$R_x(-\theta) = \begin{bmatrix} 1 & 0 & 0 \ 0 & \cos\theta & \sin\theta \ 0 & -\sin\theta & \cos\theta \end{bmatrix}, \quad R_y(-\theta) = \begin{bmatrix} \cos\theta & 0 & -\sin\theta \ 0 & 1 & 0 \ \sin\theta & 0 & \cos\theta \end{bmatrix}$$

$$R_z(-\theta) = \begin{bmatrix} \cos\theta & \sin\theta & 0 \ -\sin\theta & \cos\theta & 0 \ 0 & 0 & 1 \end{bmatrix}$$

Example: rotate the points $(0,0,0)$, $(2,3,0)$, $(5,4,0)$ clockwise by $90^\circ$ about the line $y = 4$ (parallel to the x-axis, at $z = 0$). Shift the axis to the x-axis (subtract 4 from y), rotate about x, then shift back. With $\cos 90^\circ = 0$ and $\sin 90^\circ = 1$: $y' = (y-4)\cos\theta + z\sin\theta + 4$ and $z' = -(y-4)\sin\theta + z\cos\theta$.

Point$y - 4$New point
(0, 0, 0)-4(0, 4, 4)
(2, 3, 0)-1(2, 4, 1)
(5, 4, 0)0(5, 4, 0)

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

Open this answer on its own page →

Translation transformation

2082 · 5 marks

Explain the concept of translation transformation in 2D graphics. Discuss the effect of translation on objects. [5]

Translation is a geometric transformation that moves every point of an object by a fixed distance in a specified direction. It shifts an object from one position to another without changing its shape, size, or orientation. For a point P(x, y), translation by distance tx along the x-axis and ty al...

Open this answer on its own page →

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 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):

OriginalRotated
$(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:

  1. A line $y = 4$ in a 2D figure is a pivot for an in-plane rotation about the z-axis, not the y-axis.
  2. 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.

Open this answer on its own page →

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]

  • Endpoint A = $(9, 3)$ - Endpoint B = $(12, 10)$ - Line of reflection: $x = 7$ (vertical line, $k = 7$) For any point $(x, y)$ reflected about the vertical line $x = k$: $$(x, y) \rightarrow (2k - x,\ y)$$ The $y$-coordinate is unchanged; the $x$-coordinate is mirrored. Here $k = 7$, so
Open this answer on its own page →

2079 · 5 marks

Write short notes on: a. Shearing and Scaling b. Line Clipping [5]

Scaling is a transformation that changes the size of an object by multiplying coordinates by scale factors. Transformation equations: - x' = sx · x - y' = sy · y Where sx and sy are scale factors for x and y directions respectively. Matrix form: Properties: - If sx = sy 1: uniform enlargement - I...

Open this answer on its own page →

Successive rotations and angle addition

0 · 5 marks

Prove that successive rotation is equal to addition of angles. [5]

Theorem: When two rotations are applied successively about the same point, the result is equivalent to a single rotation by an angle equal to the sum of the individual rotation angles. --- Let us consider a point P in a 2D plane and apply two successive rotations about the origin O: - First rotat...

Open this answer on its own page →