applications-to-computer-graphics.wiki (1594B)
1 == Applications to computer graphics == 2 graphics are stored in a matrix, such as this: 3 4 {{file:img/graphics-coordinate-matrix.png|Graphics coordinate matrix}} {{file:img/vector-letter-n.png|Vector letter N}} 5 6 === Homogeneous coordinates === 7 ==== 2D ==== 8 each point (x, y) in 2D can be identified with point (x, y, 1) in 3D. so we say that (x, y) has homogeneous coordinates (x, y, 1). 9 10 e.g. translation is not a linear transformation. but $(x, y) \mapsto (x+h, y+k)$ can be written in homogeneous coordinates as $(x, y, 1) \mapsto (x+h, y+k, 1)$, and can be computed using matrix multiplication: 11 12 $\begin{bmatrix} 1 & 0 & h\\ 0 & 1 & k\\ 0 & 0 & 1\end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} = \begin{bmatrix} x+h \\ y+k \\ 1 \end{bmatrix}$ 13 14 ==== 3D ==== 15 (X, Y, Z, H) are homogeneous coordinates for (x, y, z) if H ≠ 0 and 16 17 $x = \frac{X}{H}, \quad y = \frac{Y}{H}, \quad \text{and} \; z = \frac{Z}{H}$ 18 19 === Matrices for typical transformations === 20 {{file:img/typical-transformations.png|Typical transformations}} 21 22 === Composite transformations === 23 when you need two or more basic transformations, such a composite transformation is a matrix multiplication. 24 25 matrices for new transformations are "prepended" in multiplication. so if you're rotating, then translating, the calculation is `[matrix for translation][matrix for rotation]`. 26 27 === Perspective projections === 28 maps each point (x, y, z) onto an image point (x*, y*, 0) so that two points and eye position (center of projection) are on a line. 29 30 {{file:img/perspective-projection-diagram.png|Perspective projection diagram}} 31