Unit 4: Clipping & Projection - Computer Graphics Notes - CSU358

Unit 4: Clipping & Projection

4.1 Clipping Algorithms

Analogy: Taking a photo. Anything outside the viewfinder doesn't get recorded.

1. Cohen-Sutherland Line Clipping

Uses 4-bit Region Codes (TBRL - Top, Bottom, Right, Left) to quickly accept or reject lines.

The Logic:

2. Mid-Point Subdivision Clipping

Concept: A "Binary Search" approach. Instead of calculating complex intersections (slow math), it simply cuts the line in half.

3. Sutherland-Hodgman Polygon Clipping

Problem: Clipping a shape is harder than a line because cutting off a corner creates new edges.

The Pipeline Approach:

Clip the entire polygon against one boundary at a time.

  1. Input Polygon $\rightarrow$ Left Clipper $\rightarrow$ Output
  2. Input $\rightarrow$ Right Clipper $\rightarrow$ Output
  3. Input $\rightarrow$ Top Clipper $\rightarrow$ Output
  4. Input $\rightarrow$ Bottom Clipper $\rightarrow$ Final Polygon
Exam Warning (Numericals):

Ensure you can solve a Liang-Barsky clipping problem. It is more efficient than Cohen-Sutherland and frequently carries 10+ marks.

mindmap
  root((Clipping Logic))
    Code Checks
      Cohen-Sutherland
      TBRL Codes
      Accept/Reject
    Divide Checks
      Mid-Point Subdiv
      Binary Search
      Good for Hardware
    Shape Checks
      Sutherland-Hodgman
      Pipeline Cutters
      L -> R -> T -> B
            

4.2 Projections

Analogy: Casting a shadow.

Feature Parallel Projection Perspective Projection
Visual Parallel lines stay parallel. No vanishing point. Parallel lines meet at a "Vanishing Point".
Size True to size (Measurements are accurate). Distant objects look smaller (Realistic).
Use Case Architects, Engineers, CAD. Games, Movies, Human Vision.

Sub-Types

mindmap
  root((View Types))
    Parallel
      CAD / Architect
      True Size
      No Vanishing Point
    Perspective
      Human Eye / Game
      Shrink with Dist
      Vanishing Points
            

4.3 The Math (Deep Dive)

Formulas often asked in "Hard" sections.

1. Perspective Formula (Similar Triangles)

Concept: Divide by depth ($z$).

If simple camera at Origin and Screen at distance $d$: $$x' = x \cdot \frac{d}{z}$$ $$y' = y \cdot \frac{d}{z}$$
(As $z$ increases, $x'$ gets smaller).

2. Oblique Projection Math

The front face is flat ($z=0$), but sides go back at angle $\phi$.

Variations:

3. Vanishing Points Logic

Tricky Question: What makes it 1, 2, or 3 point perspective?

Answer: It depends on how many axes ($x,y,z$) intersect/cut the Projection Plane.

mindmap
  root((Projection Math))
    Perspective
      Divide by Z
      x' = x (d/z)
    Oblique
      Add Offset
      x' = x + LzCos
      Cavalier vs Cabinet
    Vanishing Pts
      Axes Intersected
      1-Pt (Z only)
      2-Pt (X, Z)
      3-Pt (X, Y, Z)