# Lecture 001

## Perspective Projection

Assume camera has unit size, then:

• $v = \frac{y}{z}$ (it just the slope, or height difference divided by distance)

• $u = \frac{x}{z}$ (width difference divided by distance)

Draw an image: assume camera at $C = (a, b, c)$:

1. for each vertex $V = (x, y, z)$ calculate $V' = V - C$
2. let $V' = (x', y', z')$, then $(u, v) = (\frac{x}{z}, \frac{y}{z})$

## Rasterization

### Rasterization Accuracy

Thickness Rule: turn on a pixel if the line (with a specified width) occupies some percentage of a pixel

### Rasterization Performance

Naive Rasterization: to cover $n$ pixel, if we check the condition for every pixel we probably need $n^2$ times.

Incremental Line Rasterization: given endpoints $(u_1, v_1), (u_2, v_2)$

• we know the slope $s = \frac{v_2 - v_1}{u_2 - u_1}$

• assume $u_1 < u_2 \land v_1 < v_2 \land 0 < s < 1$, we can write the following code

''' v = v1; for (u = u1; u <= u2; u++) { v += s; draw(u, round(v)) } '''

Table of Content