4 Three Dimensional Geometric Transformation

Computer Graphics · Unit 4 · 5 hrs

Three-Dimensional Geometric Transformation

Exam-focused notes for Three-Dimensional Geometric Transformation (Computer Graphics, CSC214): what the TU syllabus asks and how it has actually been tested, with 5 solved past questions from this unit.

Three-Dimensional Geometric Transformation in short

Extending transformations and viewing from two to three dimensions adds a $z$ coordinate to every point and matrix, and adds a genuinely new problem that 2D viewing never faced: collapsing three dimensions onto the two-dimensional screen through a projection. This chapter carries the 2D transformation matrices into their $4\times4$ homogeneous form, then covers the 3D viewing pipeline and the two families of projection.

Three-Dimensional Geometric Transformation: notes

Three-Dimensional translation, Rotation, Scaling, Reflection and Shearing

In three dimensions a point is written in homogeneous form as $(x_h, y_h, z_h, h)$, again with $h=1$ for ordinary points, so $(x,y,z)$ becomes $(x,y,z,1)$ and every transformation is a $4\times4$ matrix applied as $P' = M,P$.

Translation by $(t_x, t_y, t_z)$: $$ T(t_x,t_y,t_z) = \begin{bmatrix} 1&0&0&t_x \ 0&1&0&t_y \ 0&0&1&t_z \ 0&0&0&1 \end{bmatrix}. $$

Scaling relative to the origin by $(s_x, s_y, s_z)$: $$ S(s_x,s_y,s_z) = \begin{bmatrix} s_x&0&0&0 \ 0&s_y&0&0 \ 0&0&s_z&0 \ 0&0&0&1 \end{bmatrix}. $$

Rotation in 3D is only unambiguous once an axis is fixed, since rotating "by $\theta$" now needs a rotation axis rather than just a signed angle. Rotation about the $z$-axis affects $x$ and $y$ exactly as the 2D case did, leaving $z$ untouched; rotation about $x$ and $y$ are the same idea cycled through the coordinates: $$ R_z(\theta) = \begin{bmatrix} \cos\theta & -\sin\theta & 0 & 0 \ \sin\theta & \cos\theta & 0 & 0 \ 0&0&1&0 \ 0&0&0&1 \end{bmatrix}, \quad R_x(\theta) = \begin{bmatrix} 1&0&0&0 \ 0&\cos\theta&-\sin\theta&0 \ 0&\sin\theta&\cos\theta&0 \ 0&0&0&1 \end{bmatrix}, \quad R_y(\theta) = \begin{bmatrix} \cos\theta&0&\sin\theta&0 \ 0&1&0&0 \ -\sin\theta&0&\cos\theta&0 \ 0&0&0&1 \end{bmatrix}. $$

As a check, rotating the point $(1,0,0)$ by $90°$ about the $z$-axis using $R_z(90°)$ gives $(\cos 90° \cdot 1,\ \sin 90° \cdot 1,\ 0) = (0,1,0)$, exactly the expected quarter-turn of the $x$-axis onto the $y$-axis.

Reflection in 3D mirrors an object through a coordinate plane rather than a coordinate axis. Reflection through the $xy$-plane (i.e. about the plane $z=0$) keeps $x,y$ and negates $z$; through the $yz$-plane it keeps $y,z$ and negates $x$; through the $xz$-plane it keeps $x,z$ and negates $y$: $$ M_{xy} = \operatorname{diag}(1,1,-1,1), \qquad M_{yz} = \operatorname{diag}(-1,1,1,1), \qquad M_{xz} = \operatorname{diag}(1,-1,1,1). $$

Shearing in 3D distorts one coordinate in proportion to the other two, keeping planes parallel to a chosen axis undistorted. A $z$-axis shear, which leaves $z$ fixed while shifting $x$ and $y$ in proportion to $z$, is $$ SH_z(a,b) = \begin{bmatrix} 1&0&a&0 \ 0&1&b&0 \ 0&0&1&0 \ 0&0&0&1 \end{bmatrix}, \qquad x' = x + a,z, \quad y' = y + b,z, \quad z' = z, $$

and shears relative to the $x$- or $y$-axis are built the same way by placing the two proportionality constants in the other rows.

What this unit covers

  • Three-Dimensional translation, Rotation, Scaling, Reflection and Shearing
  • Three-Dimensional Composite Transformations
  • Three-Dimensional Viewing: Viewing pipeline, world to screen viewing transformation, Projection concepts(Orthographic, parallel, perspective projections)

Three-Dimensional Viewing

2081 · 5 marks

Differentiate between parallel projection and perspective projections. [5]

Parallel Projection: In parallel projection, the distance from the center of projection (COP) to the projection plane is infinite. Parallel lines are drawn from each vertex of the object in a specified direction until they intersect the view plane. A direction of projection is specified instead o...

Open this answer on its own page →

2080 · 10 marks

Differentiate between parallel and perspective projection with suitable diagram. Illustrate the window to viewport transformation with example.[10]

Show solved answer

Parallel vs Perspective Projection and Window-to-Viewport Transformation


Part 1: Parallel Projection vs Perspective Projection

Definition

Parallel Projection: In parallel projection, the projectors (lines of projection) are parallel to each other and perpendicular (or at an angle) to the projection plane. The center of projection is at infinity.

Perspective Projection: In perspective projection, the projectors converge at a single point called the center of projection (eye point or viewpoint). Objects farther away appear smaller, giving a realistic view.


Diagram

Parallel Projection

Object         Projection Plane
  A ---------> A'
  B ---------> B'       (parallel lines)
  C ---------> C'
  
  Projectors are parallel to each other

Perspective Projection

                        Projection Plane
  A  \                      A'
  B   \----> Center  -----> B'
  C  /    of Projection     C'
  
  Projectors converge at one point (eye)

Differences Between Parallel and Perspective Projection

BasisParallel ProjectionPerspective Projection
ProjectorsParallel to each otherConverge at a single point
Center of ProjectionAt infinityAt a finite point
RealismLess realisticMore realistic
Distance EffectObject size does not change with distanceFarther objects appear smaller
PreservationPreserves shape and sizeDoes not preserve shape and size
UsageEngineering drawings, CADComputer graphics, games, animations
ComplexitySimpler to computeMore complex to compute
TypesOrthographic, ObliqueOne-point, Two-point, Three-point

Transformation Matrix

Parallel Projection onto the xy-plane:

$$M_{parallel} = \begin{bmatrix} 1 & 0 & 0 & 0 \ 0 & 1 & 0 & 0 \ 0 & 0 & 0 & 0 \ 0 & 0 & 0 & 1 \end{bmatrix}$$

The z-coordinate is simply dropped (set to 0).

Perspective Projection (with center of projection at distance d along z-axis):

$$M_{perspective} = \begin{bmatrix} 1 & 0 & 0 & 0 \ 0 & 1 & 0 & 0 \ 0 & 0 & 1 & 0 \ 0 & 0 & 1/d & 0 \end{bmatrix}$$

The projected coordinates are:

$$x_p = \frac{x}{z/d}, \quad y_p = \frac{y}{z/d}$$


Part 2: Window to Viewport Transformation

Definitions

  • Window: A rectangular region in the world coordinate system that defines what part of the scene is to be viewed.
  • Viewport: A rectangular region on the display/screen device where the window contents are mapped and displayed.

Diagram

World Coordinate System          Screen/Device Coordinate System
                                 
  yw_max +--------+              yv_max +----------+
         |        |                    |          |
         | WINDOW |    ========>       | VIEWPORT |
         |        |                    |          |
  yw_min +--------+              yv_min +----------+
         xw_min  xw_max                xv_min    xv_max

Steps of Window to Viewport Transformation

The transformation is done in three steps (composite transformation):

Step 1: Translate window to origin

Move the lower-left corner of the window to the origin.

$$T_1 = T(-x_{w_{min}},\ -y_{w_{min}})$$

Step 2: Scale to viewport size

Scale the window so it matches the size of the viewport.

$$S = S(S_x,\ S_y)$$

Where the scaling factors are:

$$S_x = \frac{x_{v_{max}} - x_{v_{min}}}{x_{w_{max}} - x_{w_{min}}}$$

$$S_y = \frac{y_{v_{max}} - y_{v_{min}}}{y_{w_{max}} - y_{w_{min}}}$$

Step 3: Translate to viewport position

Move the scaled object to the viewport's actual position on screen.

$$T_2 = T(x_{v_{min}},\ y_{v_{min}})$$


Composite Transformation Matrix

$$T_{wv} = T(x_{v_{min}},\ y_{v_{min}}) \cdot S(S_x,\ S_y) \cdot T(-x_{w_{min}},\ -y_{w_{min}})$$

The final mapping equations for any point $(x_w, y_w)$ in the window to $(x_v, y_v)$ in the viewport:

$$\boxed{x_v = x_{v_{min}} + (x_w - x_{w_{min}}) \cdot S_x}$$

$$\boxed{y_v = y_{v_{min}} + (y_w - y_{w_{min}}) \cdot S_y}$$


Numerical Example

Given:

  • Window: $x_{w_{min}} = 20,\ x_{w_{max}} = 80,\ y_{w_{min}} = 10,\ y_{w_{max}} = 60$
  • Viewport: $x_{v_{min}} = 0,\ x_{v_{max}} = 40,\ y_{v_{min}} = 0,\ y_{v_{max}} = 30$
  • Point in window: $P_w = (50, 40)$

Step 1: Calculate scaling factors

$$S_x = \frac{40 - 0}{80 - 20} = \frac{40}{60} = 0.667$$

$$S_y = \frac{30 - 0}{60 - 10} = \frac{30}{50} = 0.6$$

Step 2: Apply the mapping equations to $P_w = (50, 40)$

$$x_v = x_{v_{min}} + (x_w - x_{w_{min}}) \cdot S_x = 0 + (50 - 20) \times 0.667 = 30 \times 0.667 = 20.0$$

$$y_v = y_{v_{min}} + (y_w - y_{w_{min}}) \cdot S_y = 0 + (40 - 10) \times 0.6 = 30 \times 0.6 = 18.0$$

$$\boxed{P_v = (20,\ 18)}$$


Conclusion

The point $(50, 40)$ in the window maps to $(20, 18)$ in the viewport. This is exactly the composite transformation described above: translate the window's lower-left corner to the origin, scale by the ratio of viewport size to window size (here $S_x = 0.667$, $S_y = 0.6$, since the viewport is smaller than the window in both dimensions), then translate to the viewport's actual position on the screen. Because $S_x \neq S_y$ in this example, the mapping is a non-uniform scale, so shapes in the window are stretched differently along x and y once displayed in the viewport.

Open this answer on its own page →

2078 · 10 marks

Question

Define orthographic, parallel, and perspective projections. Consider a region defined by the position vector P below, relative to global XYZ axis system. It is rotated by +30° about X-axis and passes through points (1.5, 1.5, 1.5). Find the final position of the region.

$$P = \begin{bmatrix} 1 & 1 & 2 & 1 \ 2 & 1 & 2 & 1 \ 2 & 2 & 2 & 1 \ 1 & 2 & 2 & 1 \end{bmatrix}$$

[10]

Parallel Projection: The projectors (lines joining object points to the view plane) are parallel to each other; the centre of projection is located at infinity. It preserves relative proportions and is used for engineering/technical drawings. Orthographic Projection: A special case of parallel pr...

Open this answer on its own page →

2077 · 5 marks

Differentiate between orthographies, parallel, and perspective projections. [5]

Projection is the process of mapping a 3D object onto a 2D plane (view plane). The two major types are Parallel Projection and Perspective Projection. Orthographic projection is a subtype of parallel projection. --- - In parallel projection, the projectors (lines of projection) are parallel to ea...

Open this answer on its own page →

Three-Dimensional translation, Rotation, Scaling, Reflection and Shearing

2075 · 5 marks

Derive the relation for three-dimensional translation and rotation. [5]

--- Translation moves a point linearly in space. Let point P(x, y, z) be translated by translation vector T(tx, ty, tz) to produce image point P'(x', y', z'). The translated coordinates are obtained by adding the translation distances to each coordinate: $$x' = x + tx$$ $$y' = y + ty$$ $$z' = z +...

Open this answer on its own page →