2080 2

CSC214 ยท 2080 ยท 10 marks

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

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

Computer GraphicsChapter 4: Three-Dimensional Geometric TransformationThree-Dimensional Viewing

Quick answer

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

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.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.