Page 1: Computer Graphics: Introduction
Computer Graphics (from the two words: Computer + Graphics) introduces how images are generated, manipulated, and displayed using electronic systems.
Computer Graphics
Computer → An electronic device.
Graphics → From the Greek word graphikos, meaning “to draw.”
Types of Graphics Devices
- CRT (Cathode Ray Tube): The vacuum tube that generates and directs an electron beam onto a phosphor screen.
- CRT Monitor: The complete display device that houses a CRT and associated electronics to render images.
CRT Working Principle
When an electron beam is emitted from the electron gun, it is directed toward the phosphor-coated screen. A focusing anode narrows the beam, while electromagnetic deflection coils (horizontal and vertical) position it at precise locations on the screen.
The phosphor coating emits light when struck by electrons - this phenomenon is called fluorescence. Because this light persists only briefly, the image must be redrawn repeatedly - a process called refreshing.
What property of the phosphor coating causes it to emit light, and why is refreshing needed?
A: Fluorescence emits light when struck by electrons. Refreshing is needed because this light fades rapidly (low persistence).
Basic Idea
- The electron gun produces a stream of electrons.
- These electrons are accelerated and focused into a narrow beam.
- The beam is deflected horizontally and vertically to reach specific points on the screen.
- Beam intensity controls the brightness of each pixel.
- The screen is refreshed many times per second (the refresh rate).
Diagram (from notebook)
Depicts the electron gun, focusing anode, horizontal and vertical deflection coils, and the phosphor screen where the image appears.
graph TD
A[Electron Gun]-->B[Focusing Anode]
B --> C[Deflection Coils Horizontal & Vertical]
C --> D[Phosphor-Coated Screen]
Page 2: Types of CRT Displays
There are mainly two types of CRT displays used in computer graphics:
- Random Scan Display (also known as Vector Display)
- Raster Scan Display
1. Random Scan Display
- Also called Vector Display or Stroke Writing Display.
- Used in older systems like early CAD/CAM and oscilloscopes.
- The electron beam is directed only along the lines forming the image.
- The beam directly draws the picture component by component.
- Suitable for line drawings, wireframes, and engineering diagrams.
Advantages
- High resolution.
- Smooth line generation.
Disadvantages
- Not suitable for complex or filled images.
- Limited color and shading support.
Why is Random Scan (Vector) display better for line drawings than Raster Scan?
A: It draws lines significantly smoother (no jagged edges/aliasing) because the beam follows the exact line path.
2. Raster Scan Display
- This is the standard display method used in modern monitors and TVs.
- The screen is divided into a grid of small dots called pixels.
- The electron beam scans the screen line by line from top to bottom, left to right.
- Each pass is known as a refresh cycle or frame.
Advantages
- Suitable for displaying images, animations, and colors.
- Supports high detail and realism.
Disadvantages
- Requires large memory (Frame Buffer).
- Resolution depends on pixel density.
Raster vs Random Scan (Comparison Table)
| Feature | Random Scan | Raster Scan |
|---|---|---|
| Image Representation | Line drawings | Pixel-based (bitmap) |
| Refresh Type | Vector-based refresh | Line-by-line refresh |
| Memory Requirement | Low | High |
| Use Case | CAD, wireframe | Games, UI, animation |
| Quality | Smooth lines | Possible aliasing |
| Color Support | Limited | Full color supported |
How does Raster Scan create an image?
A: It scans the screen line-by-line (top to bottom), turning pixels on/off based on the Frame Buffer's data.
Page 3: Frame Buffer and Display Devices
Frame Buffer
A frame buffer is a memory area that stores the intensity (brightness) and color information for each pixel on the screen.
It acts as a digital image storage before the display is drawn.
Each location in the frame buffer corresponds to one pixel on the screen.
Example: If the screen has a resolution of 640×480, then the frame buffer must store 640 × 480 = 307,200 pixels.
What does the Frame Buffer store?
A: It stores the intensity/color values for every single pixel on the screen.
Bit Depth (Color Resolution)
Each pixel can store different levels of color information depending on the number of bits used per pixel.
| Bits per Pixel | Colors Represented |
|---|---|
| 1 bit | 2 colors (black/white) |
| 4 bits | 16 colors |
| 8 bits | 256 colors |
| 16 bits | 65,536 colors |
| 24 bits | 16.7 million colors (True Color) |
Frame Buffer Example
If a display uses 1024×768 resolution and 8-bit color,
→ Frame buffer size = 1024 × 768 × 8 bits = 6,291,456 bits ≈ 0.75 MB
$$1024 \times 768 \times 8\ \text{bits} = 6{,}291{,}456\ \text{bits} \approx 0.75\ \text{MB}$$
How do you calculate Frame Buffer size?
A: Size = Resolution Width × Height × Bit Depth (bits per pixel).
Display Devices
- CRT (Cathode Ray Tube) – Traditional display with electron gun and phosphor screen.
- LCD (Liquid Crystal Display) – Uses liquid crystals and a backlight.
- LED Display – Similar to LCD but uses light-emitting diodes for backlighting.
- Plasma Display – Uses ionized gas cells (plasma) to produce images.
- OLED Display – Each pixel emits light individually; better contrast and energy efficiency.
Key Terms
- Refresh Rate: Number of times the screen is redrawn per second (e.g., 60Hz, 120Hz).
- Persistence: Time for a pixel to fade after the beam passes (low persistence = less flicker).
- Resolution: Number of distinct pixels in each dimension (e.g., 1920×1080).
Page 4: Input Devices & Display Techniques
This page lists common input devices used for interaction with graphical systems and summarizes foundational display techniques.
Input Devices in Computer Graphics
These are the devices that allow interaction between the user and the graphical system.
- Keyboard
-
Used to input alphanumeric data and commands.
-
Commonly used in menu-driven and text-based graphical interfaces.
-
- Mouse
-
A pointing device used to move a cursor on the screen.
-
Detects motion and translates it into cursor movement.
-
Actions like click, double-click, and drag are used in GUIs.
-
- Light Pen
-
A photosensitive pen-like device that detects light emitted from the CRT screen.
-
When touched to the screen, it identifies the exact position.
-
Used in design and drawing systems.
-
- Joystick
-
Used for interactive control in games or simulations.
-
Allows movement in multiple directions (up, down, left, right).
-
- Trackball
-
A stationary input device with a rotating ball to control pointer movement.
-
Works as an upside-down mouse.
-
- Scanner
-
Converts physical images or documents into digital form.
-
- Digitizer
-
Converts hand-drawn graphics into digital coordinates.
-
Used in CAD and design applications.
-
Display Techniques
- Point Plotting
-
The simplest display technique.
-
Uses individual pixel plotting to form images.
-
Example: Line or curve drawing algorithms.
-
- Line Drawing
-
A series of plotted points between two coordinates to form straight lines.
-
Common algorithms:
-
DDA (Digital Differential Analyzer) Algorithm
-
Bresenham’s Line Algorithm
-
-
- Character Generation
-
Used to display text on the screen.
-
Each character is represented as a matrix of pixels (e.g., 5×7 or 8×8 grid).
-
- Image Display
-
Images are displayed by reading pixel values from the frame buffer and refreshing the screen repeatedly.
-
Page 5: Line Drawing Algorithm (DDA Algorithm)
The DDA (Digital Differential Analyzer) is a scan conversion algorithm used to draw straight lines between two points by computing intermediate positions from the start to the end coordinates.
Concept
A line can be represented by the equation:
$$ y = mx + c $$
where the slope is given by
$$ m = \frac{y_2 - y_1}{x_2 - x_1} $$
and the two endpoints are \( (x_1, y_1) \) and \( (x_2, y_2) \).
Algorithm Steps
-
Input: Starting point \( (x_1, y_1) \), ending point \( (x_2, y_2) \).
-
Compute differences:
$$ \Delta x = x_2 - x_1,\quad \Delta y = y_2 - y_1 $$
-
Determine steps:
$$ \text{steps} = \max\left(|\Delta x|,\ |\Delta y|\right) $$
-
Calculate increments:
$$ x_{\text{inc}} = \frac{\Delta x}{\text{steps}},\quad y_{\text{inc}} = \frac{\Delta y}{\text{steps}} $$
-
Initialize:
$$ x = x_1,\quad y = y_1 $$
-
Iterate for each step:
-
Plot the pixel at \( \big(\mathrm{round}(x),\ \mathrm{round}(y)\big) \).
-
Update:
$$ x \leftarrow x + x_{\text{inc}},\quad y \leftarrow y + y_{\text{inc}} $$
-
Example
Draw a line from \( (2, 2) \) to \( (8, 5) \).
$$ \Delta x = 8 - 2 = 6,\quad \Delta y = 5 - 2 = 3 $$
$$ \text{steps} = 6 $$
$$ x_{\text{inc}} = 1,\quad y_{\text{inc}} = 0.5 $$
Intermediate \((x, y)\) updates (before rounding): \((2, 2),\ (3, 2.5),\ (4, 3),\ (5, 3.5),\ (6, 4),\ (7, 4.5),\ (8, 5)\).
Advantages
-
Simple and easy to implement.
-
Handles all types of slopes.
What is the main disadvantage of the DDA algorithm?
A: It relies on floating-point arithmetic and rounding, which makes it slower than integer-only methods.
Disadvantages
-
Uses floating-point arithmetic (slower than pure integer methods).
-
Requires rounding of coordinates.
Page 6: Bresenham’s Line Drawing Algorithm
Purpose
Bresenham’s algorithm is an incremental scan conversion algorithm used to draw a line efficiently using only integer calculations - no floating-point arithmetic as in DDA.
Concept
For a line between two points \( (x_1, y_1) \) and \( (x_2, y_2) \), the slope is \( m = \frac{\Delta y}{\Delta x} \).
-
If \( 0 \le m \le 1 \), the line is gently sloped - advance primarily in \(x\).
-
If \( m > 1 \), the line is steep - advance primarily in \(y\).
Below is the case \( 0 \le m \le 1 \).
Algorithm Logic (for \(0 \le m \le 1\))
Let \( \Delta x = x_2 - x_1 \) and \( \Delta y = y_2 - y_1 \). Define the decision parameter:
$$ p_0 = 2\Delta y - \Delta x $$
For each increment in \(x\):
-
If \( p_k < 0 \): next point \( (x+1,\ y) \); update \( p_{k+1} = p_k + 2\Delta y \).
-
Else: next point \( (x+1,\ y+1) \); update \( p_{k+1} = p_k + 2\Delta y - 2\Delta x \).
Repeat until \( x = x_2 \).
Algorithm Steps
-
Input the two endpoints \( (x_1, y_1) \), \( (x_2, y_2) \).
-
Compute \( \Delta x = x_2 - x_1 \), \( \Delta y = y_2 - y_1 \).
-
Initialize the decision parameter \( p = 2\Delta y - \Delta x \) and set \( x = x_1,\ y = y_1 \).
-
For \( x \) from \( x_1 \) to \( x_2 \):
-
Plot the pixel \( (x, y) \).
-
If \( p < 0 \): set \( p \leftarrow p + 2\Delta y \).
-
Else: set \( y \leftarrow y + 1 \) and \( p \leftarrow p + 2\Delta y - 2\Delta x \).
-
Increment \( x \leftarrow x + 1 \).
-
Why is Bresenham's algorithm faster than DDA?
A: It uses only integer addition and subtraction, avoiding costly floating-point multiplication/division.
Example
For the line from \( (2, 2) \) to \( (9, 6) \):
$$ \Delta x = 9 - 2 = 7,\quad \Delta y = 6 - 2 = 4 $$
$$ p_0 = 2\Delta y - \Delta x = 8 - 7 = 1 $$
| Iteration \(k\) | \(p_k\) (before decision) | Decision | Plotted \((x, y)\) | \(p_{k+1}\) (after update) |
|---|---|---|---|---|
| 0 | 1 | \(p_k \ge 0 \Rightarrow y \leftarrow y+1\) | (2, 2) | \(1 + 8 - 14 = -5\) |
| 1 | -5 | \(p_k < 0 \Rightarrow y\ \text{same}\) | (3, 3) | \(-5 + 8 = 3\) |
| 2 | 3 | \(p_k \ge 0 \Rightarrow y \leftarrow y+1\) | (4, 3) | \(3 + 8 - 14 = -3\) |
| 3 | -3 | \(p_k < 0 \Rightarrow y\ \text{same}\) | (5, 4) | \(-3 + 8 = 5\) |
| 4 | 5 | \(p_k \ge 0 \Rightarrow y \leftarrow y+1\) | (6, 4) | \(5 + 8 - 14 = -1\) |
| 5 | -1 | \(p_k < 0 \Rightarrow y\ \text{same}\) | (7, 5) | \(-1 + 8 = 7\) |
| 6 | 7 | \(p_k \ge 0 \Rightarrow y \leftarrow y+1\) | (8, 5) | \(7 + 8 - 14 = 1\) |
| 7 | 1 | \(x = x_2\) reached | (9, 6) | - |
The plotted points (in order) are: \((2,2),(3,3),(4,3),(5,4),(6,4),(7,5),(8,5),(9,6)\).
Advantages
-
Uses only integer arithmetic.
-
Faster and more efficient than DDA.
-
Ideal for embedded and low-level graphics systems.
Disadvantages
-
Slightly more involved control logic.
-
Requires adaptations for all slope and octant cases.
Page 7: Circle Drawing Algorithm (Mid-Point Circle Algorithm)
Objective
To draw a circle using only integer arithmetic and symmetry properties, avoiding floating-point operations.
Circle Equation
The standard equation of a circle with center at the origin \((0,0)\) and radius \(r\) is:
$$x^2 + y^2 = r^2$$
Concept
Instead of calculating every point on the circle, compute points only in one octant and use symmetry to mirror them to the other seven octants.
That is, if a point \((x, y)\) lies on the circle, then the following points also lie on it:
$$(x, y),\ (y, x),\ (-x, y),\ (-y, x),\ (x, -y),\ (y, -x),\ (-x, -y),\ (-y, -x)$$
Algorithm Idea
Start from the topmost point \((0, r)\) and move towards the x-axis while deciding whether the next pixel should be:
-
East (E) → \((x + 1, y)\)
-
South-East (SE) → \((x + 1, y - 1)\)
The decision is based on the midpoint between these two choices.
Decision Parameter
Initialize the parameter as:
$$p_0 = 1 - r$$
For each step:
-
If \(p < 0\): choose E, and update
$$p_{k+1} = p_k + 2x + 3$$
-
If \(p \ge 0\): choose SE, and update
$$p_{k+1} = p_k + 2x - 2y + 5,\quad y = y - 1$$
Increment \(x = x + 1\) after each step. Continue until \(x \ge y\).
Algorithm Steps
-
Input radius \(r\) and center \((x_c, y_c)\).
-
Initialize:
$$x = 0,\quad y = r,\quad p = 1 - r$$
-
While \(x \le y\):
-
Plot the eight symmetric points.
-
If \(p < 0\): \(p \leftarrow p + 2x + 3\)
-
Else: \(p \leftarrow p + 2x - 2y + 5,\quad y \leftarrow y - 1\)
-
\(x \leftarrow x + 1\)
-
Advantages
-
Only integer arithmetic → fast and accurate.
-
Exploits circle symmetry to reduce computation.
Applications
-
Used in CAD software, graphics engines, and clock designs.
Page 8: Mid-Point Ellipse Drawing Algorithm
Objective: Draw an ellipse efficiently using midpoint decisions and symmetry, avoiding floating-point operations.
Ellipse Equation
For an ellipse centered at the origin \((0,0)\):
$$\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$$
where a is the semi-major axis (along the x-axis) and b is the semi-minor axis (along the y-axis).
Concept
By symmetry, compute points in one quadrant (\(x\ge 0,\,y\ge 0\)) and mirror to the others. If \((x,y)\) lies on the ellipse, so do:
$$ (x,y),\ (-x,y),\ (x,-y),\ (-x,-y) $$
Region Division
-
Region 1: slope \(<1\) → advance primarily in x (choose between East (E) and South-East (SE)).
-
Region 2: slope \(>1\) → advance primarily in y (choose between South (S) and South-East (SE)).
Decision Parameters
Region 1 (slope < 1)
Initialize the decision parameter at \((x,y)=(0,b)\):
$$p_1=b^2-a^2b+\frac{1}{4}a^2$$
Iterate while \(2b^2x < 2a^2y\):
-
If \(p_1<0\): move E, \(x\leftarrow x+1\), update
$$p_1 \leftarrow p_1 + 2b^2x + b^2$$
-
Else: move SE, \(x\leftarrow x+1,\ y\leftarrow y-1\), update
$$p_1 \leftarrow p_1 + 2b^2x - 2a^2y + b^2$$
Region 2 (slope > 1)
Initialize at the boundary point reached from Region 1:
$$p_2=b^2\!\left(x+\tfrac{1}{2}\right)^2 + a^2\!\left(y-1\right)^2 - a^2b^2$$
Iterate while \(y\ge 0\):
-
If \(p_2>0\): move S, \(y\leftarrow y-1\), update
$$p_2 \leftarrow p_2 - 2a^2y + a^2$$
-
Else: move SE, \(x\leftarrow x+1,\ y\leftarrow y-1\), update
$$p_2 \leftarrow p_2 + 2b^2x - 2a^2y + a^2$$
Algorithm Steps Summary
-
Input \((a,b)\) and center \((x_c,y_c)\).
-
Initialize \(x=0,\ y=b,\ p_1= b^2-a^2b+\tfrac{1}{4}a^2\).
-
Region 1: while \(2b^2x < 2a^2y\), choose E or SE using \(p_1\), update as above and plot the four symmetric points.
-
Compute \(p_2=b^2(x+\tfrac{1}{2})^2 + a^2(y-1)^2 - a^2b^2\).
-
Region 2: while \(y\ge 0\), choose S or SE using \(p_2\), update as above and continue plotting symmetric points.
Pseudocode (integer arithmetic, symmetry included)
# Inputs: a, b, xc, yc
x, y = 0, b
# Region 1 init (multiply by 4 to avoid fractions):
# P1 = 4*b*b - 4*a*a*b + a*a
P1 = 4*b*b - 4*a*a*b + a*a
def plot_symmetry(xc, yc, x, y):
plot(xc + x, yc + y)
plot(xc - x, yc + y)
plot(xc + x, yc - y)
plot(xc - x, yc - y)
# Region 1
plot_symmetry(xc, yc, x, y)
while (2*b*b*x) < (2*a*a*y):
x += 1
if P1 < 0:
# move E
P1 += 8*b*b*x + 4*b*b
else:
# move SE
y -= 1
P1 += 8*b*b*x - 8*a*a*y + 4*b*b
plot_symmetry(xc, yc, x, y)
# Region 2 init (scaled by 4)
# P2 = 4*b*b*(x+0.5)^2 + 4*a*a*(y-1)^2 - 4*a*a*b*b
# Expand to keep integers:
P2 = 4*b*b*(x*x + x) + b*b + 4*a*a*((y-1)*(y-1)) - 4*a*a*b*b
# Region 2
while y >= 0:
if P2 > 0:
# move S
y -= 1
P2 += -8*a*a*y + 4*a*a
else:
# move SE
x += 1
y -= 1
P2 += 8*b*b*x - 8*a*a*y + 4*a*a
plot_symmetry(xc, yc, x, y)
Flow (high-level)
flowchart TD
A[Start: x=0, y=b, p1=b^2 - a^2 b + a^2/4] --> B{2 b^2 x < 2 a^2 y?}
B -- Yes --> C{p1 < 0?}
C -- Yes (E) --> C1[x←x+1; p1←p1 + 2 b^2 x + b^2]
C -- No (SE) --> C2[x←x+1; y←y-1; p1←p1 + 2 b^2 x - 2 a^2 y + b^2]
C1 --> B
C2 --> B
B -- No --> D["Compute p2=b^2(x+1/2)^2 + a^2(y-1)^2 - a^2 b^2"]
D --> E{y ≥ 0?}
E -- Yes --> F{p2 > 0?}
F -- Yes (S) --> F1[y←y-1; p2←p2 - 2 a^2 y + a^2]
F -- No (SE) --> F2[x←x+1; y←y-1; p2←p2 + 2 b^2 x - 2 a^2 y + a^2]
F1 --> E
F2 --> E
E -- No --> G[Done]
Advantages
-
Uses only integer arithmetic (with scaling to eliminate fractions).
-
Exploits symmetry to minimize computations.
Applications
-
3D modeling, orbital plotting, CAD, and image rendering.
Page 9: 2D Geometric Transformations
Introduction: Geometric transformations are operations used to modify the position, size, or orientation of an object in a 2D plane. There are three basic transformations: Translation, Scaling, and Rotation.
1. Translation
Moves an object from one position to another without changing its shape, size, or orientation.
$$x' = x + T_x$$
$$y' = y + T_y$$
where \((x, y)\) → original point, \((x', y')\) → translated point, and \((T_x, T_y)\) → translation distances.
Matrix Representation (Homogeneous Coordinates):
$$ \begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & T_x \\ 0 & 1 & T_y \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} $$
2. Scaling
Resizes an object by enlarging or shrinking it.
$$x' = S_x \cdot x$$
$$y' = S_y \cdot y$$
where \(S_x, S_y\) are scaling factors (greater than 1 → enlargement, less than 1 → shrink).
Matrix Representation:
$$ \begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = \begin{bmatrix} S_x & 0 & 0 \\ 0 & S_y & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} $$
3. Rotation
Rotates an object about the origin by an angle \(\theta\) (anticlockwise).
$$x' = x\cos\theta - y\sin\theta$$
$$y' = x\sin\theta + y\cos\theta$$
Matrix Representation:
$$ \begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = \begin{bmatrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} $$
Page 10: Reflection and Shearing Transformations
Reflection creates a mirror image of an object about a specified axis or line; shearing slants an object by shifting one coordinate proportionally to the other. Both are modeled cleanly using homogeneous coordinates.
Reflection
Reflection changes orientation but preserves size and shape.
About x-axis
$$x' = x,\quad y' = -y$$
Matrix form:
$$ \begin{bmatrix} x'\\[2pt] y'\\[2pt] 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0\\ 0 & -1 & 0\\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x\\[2pt] y\\[2pt] 1 \end{bmatrix} $$
About y-axis
$$x' = -x,\quad y' = y$$
Matrix form:
$$ \begin{bmatrix} x'\\[2pt] y'\\[2pt] 1 \end{bmatrix} = \begin{bmatrix} -1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x\\[2pt] y\\[2pt] 1 \end{bmatrix} $$
About origin
$$x' = -x,\quad y' = -y$$
Matrix form:
$$ \begin{bmatrix} x'\\[2pt] y'\\[2pt] 1 \end{bmatrix} = \begin{bmatrix} -1 & 0 & 0\\ 0 & -1 & 0\\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x\\[2pt] y\\[2pt] 1 \end{bmatrix} $$
About line \(y=x\)
$$x' = y,\quad y' = x$$
Matrix form:
$$ \begin{bmatrix} x'\\[2pt] y'\\[2pt] 1 \end{bmatrix} = \begin{bmatrix} 0 & 1 & 0\\ 1 & 0 & 0\\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x\\[2pt] y\\[2pt] 1 \end{bmatrix} $$
Shearing
Shearing slants an object so that lengths are preserved along axes, but interior angles change.
X-direction shear
$$x' = x + Sh_x\,y,\quad y' = y$$
Matrix form:
$$ \begin{bmatrix} x'\\[2pt] y'\\[2pt] 1 \end{bmatrix} = \begin{bmatrix} 1 & Sh_x & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x\\[2pt] y\\[2pt] 1 \end{bmatrix} $$
Y-direction shear
$$x' = x,\quad y' = y + Sh_y\,x$$
Matrix form:
$$ \begin{bmatrix} x'\\[2pt] y'\\[2pt] 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0\\ Sh_y & 1 & 0\\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x\\[2pt] y\\[2pt] 1 \end{bmatrix} $$
Combination of Transformations
Multiple transforms compose via matrix multiplication. With column vectors, the rightmost transform applies first; order matters.
$$ \mathbf{P}' \;=\; \mathbf{T}\,\mathbf{R}\,\mathbf{S}\,\mathbf{P} $$
Page 11 - 2D Transformation About an Arbitrary Point
Introduction: Until now, rotation, scaling, and reflection were performed about the origin \((0,0)\). In practice, we often need to transform an object about an arbitrary point \((x_a, y_a)\).
Rotation About an Arbitrary Point \((x_a, y_a)\)
Steps:
-
Translate the reference point to the origin: \(T(-x_a, -y_a)\).
-
Rotate by \(\theta\) about the origin: \(R(\theta)\).
-
Translate back to \((x_a, y_a)\): \(T(x_a, y_a)\).
Composite Matrix:
$$ R_{\text{arb}} \;=\; T(x_a, y_a)\; R(\theta)\; T(-x_a, -y_a) $$
Useful base matrices
$$ T(t_x,t_y)= \begin{bmatrix} 1 & 0 & t_x\\ 0 & 1 & t_y\\ 0 & 0 & 1 \end{bmatrix},\qquad R(\theta)= \begin{bmatrix} \cos\theta & -\sin\theta & 0\\ \sin\theta & \cos\theta & 0\\ 0 & 0 & 1 \end{bmatrix} $$
Closed form (homogeneous \(3\times 3\))
$$ R_{\text{arb}} \;=\; \begin{bmatrix} \cos\theta & -\sin\theta & x_a(1-\cos\theta)+y_a\sin\theta\\ \sin\theta & \cos\theta & y_a(1-\cos\theta)-x_a\sin\theta\\ 0 & 0 & 1 \end{bmatrix} $$
Scaling About an Arbitrary Point \((x_a, y_a)\)
Steps:
-
Translate object so that \((x_a, y_a)\) moves to the origin.
-
Scale about the origin by \((S_x,S_y)\).
-
Translate back to \((x_a, y_a)\).
Composite Matrix:
$$ S_{\text{arb}} \;=\; T(x_a, y_a)\; S(S_x,S_y)\; T(-x_a, -y_a) $$
Useful base matrix
$$ S(S_x,S_y)= \begin{bmatrix} S_x & 0 & 0\\ 0 & S_y & 0\\ 0 & 0 & 1 \end{bmatrix} $$
Closed form (homogeneous \(3\times 3\))
$$ S_{\text{arb}} \;=\; \begin{bmatrix} S_x & 0 & x_a(1-S_x)\\ 0 & S_y & y_a(1-S_y)\\ 0 & 0 & 1 \end{bmatrix} $$
Example (Scaling)
Scale a square of side \(2\) about point \((1,1)\) by a factor \(2\) in both axes.
-
Translate by \((-1,-1)\)
-
Scale by \((2,2)\)
-
Translate back by \((+1,+1)\)
Result: Each vertex \(\mathbf{p}\) is mapped as \( \mathbf{p}' = \mathbf{c} + S(\mathbf{p}-\mathbf{c}) \) with \(\mathbf{c}=(1,1)\) and \(S=\operatorname{diag}(2,2)\), i.e., the distance from \((1,1)\) doubles and the square’s size doubles.
Reflection About an Arbitrary Line
Procedure:
-
Translate the line so it passes through the origin.
-
Rotate the line to align with an axis (usually the \(x\)-axis).
-
Reflect about that axis.
-
Inverse-rotate and inverse-translate back.
Composite Matrix:
$$ R_{\text{line}} \;=\; T(x_a, y_a)\; R(\theta)\; \mathrm{Ref}\; R(-\theta)\; T(-x_a, -y_a) $$
Closed form for a line through \((x_a,y_a)\) with direction angle \(\theta\)
Reflection about a line through the origin at angle \(\theta\) has \(2\times2\) part \(M(\theta)=\begin{bmatrix}\cos2\theta & \sin2\theta\\ \sin2\theta & -\cos2\theta\end{bmatrix}\). For a line through \((x_a,y_a)\), the homogeneous matrix is
$$ \begin{bmatrix} \cos 2\theta & \sin 2\theta & x_a(1-\cos2\theta)-y_a\sin2\theta\\ \sin 2\theta & -\cos 2\theta & y_a(1+\cos2\theta)-x_a\sin2\theta\\ 0 & 0 & 1 \end{bmatrix} $$
Note
All composite transformations are achieved via matrix multiplication. With column vectors, the rightmost matrix acts first; order matters.
Page 12: 2D Transformation Examples & Matrix Composition
Example 1: Translate and Rotate a Point
Given: Point \(P(2,3)\); translate by \((T_x,T_y)=(4,2)\); then rotate by \(\theta=90^\circ\) about the origin.
Step 1: Translation
Transformation matrix and application:
$$ T = \begin{bmatrix} 1 & 0 & 4\\ 0 & 1 & 2\\ 0 & 0 & 1 \end{bmatrix},\quad \mathbf{P} = \begin{bmatrix} 2\\[2pt]3\\[2pt]1 \end{bmatrix},\quad \mathbf{P}' = T\,\mathbf{P} = \begin{bmatrix} 6\\[2pt]5\\[2pt]1 \end{bmatrix} $$
After translation: \(P'(6,5)\).
Step 2: Rotation \((90^\circ)\)
Rotation matrix and application:
$$ R = \begin{bmatrix} 0 & -1 & 0\\ 1 & \phantom{-}0 & 0\\ 0 & \phantom{-}0 & 1 \end{bmatrix},\qquad \mathbf{P}'' = R\,\mathbf{P}' = \begin{bmatrix} -5\\[2pt]6\\[2pt]1 \end{bmatrix} $$
Final coordinates: \(P''(-5,6)\).
Example 2: Scaling followed by Translation
Given: \(P(1,2)\). Scale by \((2,3)\), then translate by \((3,2)\).
$$ S = \begin{bmatrix} 2 & 0 & 0\\ 0 & 3 & 0\\ 0 & 0 & 1 \end{bmatrix},\quad T = \begin{bmatrix} 1 & 0 & 3\\ 0 & 1 & 2\\ 0 & 0 & 1 \end{bmatrix} $$
Composite (apply scale then translate):
$$ M = T\,S = \begin{bmatrix} 2 & 0 & 3\\ 0 & 3 & 2\\ 0 & 0 & 1 \end{bmatrix} $$
Apply to \(P\):
$$ \mathbf{P} = \begin{bmatrix} 1\\[2pt]2\\[2pt]1 \end{bmatrix},\qquad \mathbf{P}' = M\,\mathbf{P} = \begin{bmatrix} 5\\[2pt]8\\[2pt]1 \end{bmatrix} $$
Final result: \(P'(5,8)\).
Note
Matrix composition allows multiple transformations in a single multiplication. Order matters (with column vectors, the rightmost matrix acts first):
$$ T\,R \;\ne\; R\,T $$
Page 13: Homogeneous Coordinates & Transformation Composition Rules
Homogeneous Coordinates
In computer graphics, we represent a 2D point as a 3D vector \((x, y, 1)\) so that translation, rotation, scaling, and reflection can all be expressed as a single matrix multiplication.
$$ P(x,y)\;\longrightarrow\; \begin{bmatrix} x\\ y\\ 1 \end{bmatrix} $$
Why Homogeneous Coordinates?
In standard 2D coordinates, translation cannot be represented by a \(2\times2\) matrix. By augmenting points with a third coordinate (typically \(1\)), translation becomes a linear operation in \(3\times3\) form.
General Transformation Matrix (2D)
$$ \begin{bmatrix} x'\\ y'\\ 1 \end{bmatrix} = \begin{bmatrix} a & b & T_x\\ c & d & T_y\\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x\\ y\\ 1 \end{bmatrix} $$
| Term | Meaning |
|---|---|
| a, b, c, d | Rotation, scaling, and shearing parameters (linear part) |
| \(T_x, T_y\) | Translation parameters |
Composition of Transformations
Applying multiple transformations corresponds to multiplying their matrices to get one composite matrix. If the order is: 1) Scale, 2) Rotate, 3) Translate, then
$$ M \;=\; T \, R \, S \quad\Rightarrow\quad P' \;=\; M\,P $$
With column vectors, the rightmost matrix acts first.
Properties of Transformation Matrices
-
Non-Commutative: \(T\,R \ne R\,T\)
-
Associative: \((T\,R)\,S = T\,(R\,S)\)
-
Identity Matrix:
$$ I = \begin{bmatrix} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{bmatrix} $$ Applying \(I\) leaves the object unchanged.
Example: Scale then Translate
If you first scale and then translate:
$$ M \;=\; T \, S \;=\; \begin{bmatrix} S_x & 0 & T_x\\ 0 & S_y & T_y\\ 0 & 0 & 1 \end{bmatrix} $$
This matrix scales the object and then moves it to the new position \((T_x, T_y)\).
Page 14: Window to Viewport Transformation
Concept: In computer graphics, a scene is defined in a world coordinate system (logical coordinates), while the display area on the screen is a viewport (device coordinates). To render correctly, we map the chosen world window to a screen viewport. This process is called Window-to-Viewport Transformation.
Definitions
Window: Rectangular world area to be displayed, defined by corners \((x_{w_{\min}}, y_{w_{\min}})\) and \((x_{w_{\max}}, y_{w_{\max}})\).
Viewport: Rectangular screen area where the image appears, defined by \((x_{v_{\min}}, y_{v_{\min}})\) and \((x_{v_{\max}}, y_{v_{\max}})\).
Mapping Formula
For each world point \((x_w, y_w)\), the mapped viewport point \((x_v, y_v)\) is:
$$ x_v \;=\; x_{v_{\min}} \;+\; \frac{(x_w - x_{w_{\min}})\,\big(x_{v_{\max}} - x_{v_{\min}}\big)}{\,x_{w_{\max}} - x_{w_{\min}}\,} $$
$$ y_v \;=\; y_{v_{\min}} \;+\; \frac{(y_w - y_{w_{\min}})\,\big(y_{v_{\max}} - y_{v_{\min}}\big)}{\,y_{w_{\max}} - y_{w_{\min}}\,} $$
Explanation
The fractions scale world coordinates proportionally into the viewport: conceptually, world coordinates are first normalized to \([0,1]\) and then scaled and shifted to the viewport. Aspect ratio is preserved only if the window and viewport have the same width-to-height ratio; otherwise the image will be stretched or compressed.
Example
Window: \((x_{\min},y_{\min})=(10,10)\), \((x_{\max},y_{\max})=(100,100)\)
Viewport: \((x_{\min},y_{\min})=(200,200)\), \((x_{\max},y_{\max})=(400,400)\)
Point: \((55,70)\)
$$ x_v \;=\; 200 + \frac{(55-10)(400-200)}{100-10} \;=\; 200 + \frac{45\cdot 200}{90} \;=\; 200 + 100 \;=\; 300 $$
$$ y_v \;=\; 200 + \frac{(70-10)(400-200)}{100-10} \;=\; 200 + \frac{60\cdot 200}{90} \;=\; 200 + 133.33\ldots \;=\; 333.33\ldots $$
Mapped point: \((300,\; 333.33\ldots)\)
Applications
-
Used in clipping and scaling operations.
-
Enables consistent rendering across different display sizes.
Page 15: Line Clipping (Cohen–Sutherland Algorithm)
Objective
Determine which portion of a line lies inside or outside a rectangular clipping window and clip the line accordingly.
Concept
A clipping window is a rectangular area defined by:
$$\big(x_{\min},\,y_{\min}\big)\ \text{and}\ \big(x_{\max},\,y_{\max}\big)$$
A line segment may:
-
Lie completely inside the window (visible)
-
Lie completely outside the window (invisible)
-
Intersect the window boundaries (partially visible → clipping needed)
Cohen–Sutherland Algorithm
Each endpoint is assigned a 4-bit region code (outcode):
$$\text{Code: }[\,T,\ B,\ R,\ L\,]$$
-
T → above top boundary
-
B → below bottom boundary
-
R → right of right boundary
-
L → left of left boundary
Region Code Assignment
| Position | Code |
|---|---|
| Inside window | 0000 |
| Left | 0001 |
| Right | 0010 |
| Bottom | 0100 |
| Top | 1000 |
Algorithm Steps
-
Compute region codes for both endpoints \(P_1\) and \(P_2\).
-
Trivially accept: if both codes are
0000, the line is completely inside. -
Trivially reject: if the bitwise AND of the two codes is not
0000, the line is completely outside. -
Otherwise (partially inside):
-
Find the intersection of the segment with the relevant window boundary.
-
Replace the outside endpoint by this intersection point.
-
Recompute its region code and repeat until accepted or rejected.
-
Example
Clipping window: \(x_{\min}=10,\ y_{\min}=10,\ x_{\max}=80,\ y_{\max}=80\).
Line: \(P_1(5,\,20),\ P_2(90,\,70)\).
-
\(P_1\) → code
0001(Left) -
\(P_2\) → code
0010(Right)
Bitwise AND = 0000 → segment is partially visible. Compute intersections with the left and right boundaries and retain only the visible portion.
Advantages
-
Efficiently accepts or rejects trivial cases.
-
Works for all line orientations.
Limitations
-
Applicable only to rectangular clipping windows.
-
May require multiple iterations for partially visible lines.
Page 16: Liang–Barsky Line Clipping Algorithm
Introduction: The Liang–Barsky algorithm is an improvement over Cohen–Sutherland. It uses a line’s parametric form to compute boundary intersections directly, making it faster and more efficient.
Line Equation (Parametric Form)
For a segment from \(P_1(x_1,y_1)\) to \(P_2(x_2,y_2)\):
$$x = x_1 + t(x_2 - x_1),\qquad y = y_1 + t(y_2 - y_1),\qquad 0 \le t \le 1$$
Clipping Window Boundaries
Axis-aligned rectangle defined by:
$$x_{\min},\ x_{\max},\ y_{\min},\ y_{\max}$$
Boundary Conditions
To be inside the window, the point must satisfy:
$$x_{\min} \le x \le x_{\max},\qquad y_{\min} \le y \le y_{\max}$$
Substitute the parametric forms for \(x\) and \(y\) into these inequalities.
Compute Parameters
Let \( \Delta x = x_2 - x_1 \) and \( \Delta y = y_2 - y_1 \). For the four edges, define:
$$ p_k \in \{-\Delta x,\ \Delta x,\ -\Delta y,\ \Delta y\},\qquad q_k \in \{\,x_1 - x_{\min},\ x_{\max} - x_1,\ y_1 - y_{\min},\ y_{\max} - y_1\,\} $$
Ratios to consider (when \(p_k \ne 0\)):
$$t = \frac{q_k}{p_k}$$
Algorithm Steps
-
Compute all \(p_k\) and \(q_k\). Initialize \(t_1 = 0\), \(t_2 = 1\).
-
If \(p_k = 0\) and \(q_k < 0\) for any \(k\) → the line is parallel and outside → reject. If \(p_k=0\) and \(q_k \ge 0\), that boundary imposes no constraint (parallel and inside) → continue.
-
For all \(p_k < 0\) (potential entering), update \( \displaystyle t_1 = \max\!\big(t_1,\ \frac{q_k}{p_k}\big) \).
-
For all \(p_k > 0\) (potential leaving), update \( \displaystyle t_2 = \min\!\big(t_2,\ \frac{q_k}{p_k}\big) \).
-
If \(t_1 > t_2\) → no overlap of valid parameter range → reject (completely outside).
-
Otherwise, the clipped endpoints are: $$ x_{\text{clip1}} = x_1 + t_1(x_2 - x_1),\quad y_{\text{clip1}} = y_1 + t_1(y_2 - y_1) $$ $$ x_{\text{clip2}} = x_1 + t_2(x_2 - x_1),\quad y_{\text{clip2}} = y_1 + t_2(y_2 - y_1) $$ The segment between these two points is the visible portion.
Advantages
-
Fewer computations than Cohen–Sutherland (direct use of parametric form).
-
Efficient with arithmetic comparisons and ratios.
-
Handles floating-point boundaries well.
Disadvantages
-
Slightly more intricate to implement conceptually.
-
Less intuitive to visualize compared to Cohen–Sutherland’s region codes.
Page 17: Polygon Clipping (Sutherland–Hodgman Algorithm)
Objective
Clip polygons (not just lines) to fit within a rectangular clipping window. The Sutherland–Hodgman algorithm clips each polygon edge against one boundary at a time.
Concept
Input: Polygon with vertices \(P_1, P_2, \dots, P_n\)
Output: New polygon that lies inside the clipping window
The polygon is clipped sequentially against each boundary, typically in this order:
-
Left
-
Right
-
Bottom
-
Top
After all boundaries are processed, the remaining polygon is the clipped output.
Cases
For each polygon edge, consider the current vertex \(S\) and the next vertex \(P\) relative to the active clipping boundary:
| Case | Description | Action |
|---|---|---|
| 1 | Both inside | Add \(P\) |
| 2 | \(S\) inside, \(P\) outside | Add intersection only |
| 3 | \(S\) outside, \(P\) inside | Add intersection, then \(P\) |
| 4 | Both outside | Add nothing |
Algorithm Steps
-
Start with the list of input polygon vertices.
-
For each clipping boundary (left, right, bottom, top):
-
Initialize an empty output list.
-
For each edge \(S \rightarrow P\) in the current polygon list, apply the four cases above.
-
Append resulting points (intersection and/or \(P\)) to the output list.
-
Replace the current polygon list with this output list.
-
-
After all boundaries, the remaining list of vertices forms the clipped polygon.
Intersection Formula
When clipping against a boundary, compute the line–boundary intersection using the segment endpoints \((x_1,y_1)\) and \((x_2,y_2)\).
Vertical boundary (e.g., \(x = x_{\min}\)):
$$x = x_{\min}$$
$$y = y_1 + (y_2 - y_1)\,\frac{x_{\min} - x_1}{x_2 - x_1}$$
Horizontal boundary (e.g., \(y = y_{\max}\)):
$$y = y_{\max}$$
$$x = x_1 + (x_2 - x_1)\,\frac{y_{\max} - y_1}{y_2 - y_1}$$
Advantages
-
Works well with a convex clipping window (e.g., rectangle).
-
Simple, boundary-by-boundary clipping process.
Limitations
-
The clipping window must be convex. For concave clipping regions, this method may fail.
-
If clipping a concave subject polygon results in multiple disjoint pieces, Sutherland–Hodgman produces a single polygonal loop and cannot represent multiple outputs; use Weiler–Atherton in such cases.
-
Clipping is applied in sequence boundary by boundary.
Page 18: 3D Transformations
Introduction: 3D transformations extend 2D operations (translation, scaling, rotation, reflection, shearing) into three-dimensional space using homogeneous coordinates \((x, y, z, 1)\). These transformations manipulate objects along the \(x\), \(y\), and \(z\) axes.
3D Translation
Formula: \(x' = x + T_x,\; y' = y + T_y,\; z' = z + T_z\)
Matrix form:
$$ \begin{bmatrix} x'\\y'\\z'\\1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & T_x\\ 0 & 1 & 0 & T_y\\ 0 & 0 & 1 & T_z\\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x\\y\\z\\1 \end{bmatrix} $$
3D Scaling
Formula: \(x' = S_x\,x,\; y' = S_y\,y,\; z' = S_z\,z\)
Matrix form:
$$ \begin{bmatrix} x'\\y'\\z'\\1 \end{bmatrix} = \begin{bmatrix} S_x & 0 & 0 & 0\\ 0 & S_y & 0 & 0\\ 0 & 0 & S_z & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x\\y\\z\\1 \end{bmatrix} $$
3D Rotation
(a) Rotation about the X-axis
$$ \begin{bmatrix} x'\\y'\\z'\\1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & \cos\theta & -\sin\theta & 0\\ 0 & \sin\theta & \cos\theta & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x\\y\\z\\1 \end{bmatrix} $$
(b) Rotation about the Y-axis
$$ \begin{bmatrix} x'\\y'\\z'\\1 \end{bmatrix} = \begin{bmatrix} \cos\theta & 0 & \sin\theta & 0\\ 0 & 1 & 0 & 0\\ -\sin\theta & 0 & \cos\theta & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x\\y\\z\\1 \end{bmatrix} $$
(c) Rotation about the Z-axis
$$ \begin{bmatrix} x'\\y'\\z'\\1 \end{bmatrix} = \begin{bmatrix} \cos\theta & -\sin\theta & 0 & 0\\ \sin\theta & \cos\theta & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x\\y\\z\\1 \end{bmatrix} $$
Reflection in 3D
About the XY-plane
\(x' = x,\; y' = y,\; z' = -z\)
$$ \begin{bmatrix} x'\\y'\\z'\\1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & -1 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x\\y\\z\\1 \end{bmatrix} $$
About the YZ-plane
\(x' = -x,\; y' = y,\; z' = z\)
$$ \begin{bmatrix} -1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} $$
About the XZ-plane
\(x' = x,\; y' = -y,\; z' = z\)
$$ \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & -1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} $$
Shearing in 3D
Shearing distorts a 3D object by shifting one coordinate proportionally to others.
General shear matrix:
$$ \begin{bmatrix} 1 & Sh_{xy} & Sh_{xz} & 0\\ Sh_{yx} & 1 & Sh_{yz} & 0\\ Sh_{zx} & Sh_{zy} & 1 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} $$
Page 19: 3D Projections (Parallel & Perspective)
Introduction: Projection maps a 3D object onto a 2D view plane (the screen) from a given viewpoint. Two primary categories are:
-
Parallel Projection
-
Perspective Projection
Parallel Projection
All projectors (projection lines) are parallel to each other and are either perpendicular or inclined to the projection plane. No vanishing point is formed, so objects do not diminish with distance.
Types of Parallel Projection
-
Orthographic Projection - projectors are perpendicular to the plane.
-
Front View: projection on the XY-plane
-
Top View: projection on the XZ-plane
-
Side View: projection on the YZ-plane
-
-
Oblique Projection - projectors are inclined to the plane.
-
Cavalier: full scale along receding axis (typically \(45^\circ\))
-
Cabinet: half scale along receding axis (angle \(\approx 63.4^\circ\))
-
Orthographic Projection Matrix (to XY-plane)
$$ \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} $$
Perspective Projection
Projectors converge at a single point (center of projection), producing a realistic sense of depth: distant objects appear smaller.
Concept (Center at Origin, Plane \(z=d\))
$$ x'=\frac{x\,d}{z},\qquad y'=\frac{y\,d}{z} $$
Objects with smaller \(z\) (closer) appear larger; those with larger \(z\) (farther) appear smaller.
Types of Perspective Projection
-
One-point perspective - convergence along one axis (e.g., roads, tunnels)
-
Two-point perspective - convergence along two axes (common in architecture)
-
Three-point perspective - convergence along three axes (highly realistic scenes)
Comparison
| Feature | Parallel Projection | Perspective Projection |
|---|---|---|
| Projection lines | Parallel | Converge at a point |
| Depth perception | Not shown | Clearly visible |
| Realism | Less realistic | Highly realistic |
| Use | Engineering drawings | Computer graphics, animation |
Applications
-
3D modeling and rendering
-
Architectural visualization
-
CAD, animation, virtual reality
Concept Review
- Raster vs. Random Scan: Raster scans pixels line-by-line (refresh cycle) suitable for photos; Random scan draws vectors directly, ideal for sharp line art.
- Frame Buffer: Memory storing pixel intensity/color; size = Resolution × Bit Depth.
- DDA Algorithm: Scan conversion using floating-point increments; simpler but slower and accumulates rounding errors.
- Bresenham’s Algorithm: Uses integer arithmetic for efficient line drawing; determines next pixel based on a decision parameter (\(p\)).
- Mid-Point Circle / Ellipse Algorithm: Uses symmetry (8 octants / 4 quadrants) and integer decision parameter to plot shapes efficiently.
- Homogeneous Coordinates: Represent 2D points \((x,y)\) as \((x,y,1)\) to allow translation to be matrix multiplication, enabling composite transformations.
- Composite Transformations: Sequence of transforms combined by matrix multiplication (Right-to-Left order: \(M = T \cdot R \cdot S\)).
- Window-to-Viewport: Maps world coordinates (window) to screen coordinates (viewport) while maintaining relative proportions.
- Cohen-Sutherland Clipping: Uses 4-bit region codes (TBRL) to trivially accept/reject lines or clip them against boundaries.
- Liang-Barsky Clipping: Uses parametric line equations for faster clipping by solving inequalities directly.
- Sutherland-Hodgman Clipping: Clips polygons by processing vertices against each boundary sequentially (pipeline approach).
- Perspective vs. Parallel Projection: Perspective simulates depth (objects shrink with distance); Parallel preserves dimensions (good for measurements).
