geometry crash course / review
COS 350 - Computer Graphics
geometry crash course / review
geometric types
segment
segment: set of points (line) between two points
\[ \tilde\p(t) = \tilde\a + t(\tilde\b - \tilde\a) \text{ with } t \in [0,1] \]
note: linear interpolation of points, parameterized by \(t\)
\[ \begin{array}{rclcl}
\point{p}(t)
& = & \point{a} + t(\point{b} - \point{a})
& = & \point{a} + t\vector{b} - t\vector{a} \\
& = & \point{a} - t\vector{a} + t\vector{b}
& = & (1-t)\vector{a} + t\vector{b}
\end{array} \]
ray
ray: infinite line from point in a given direction
\[ \point{p}(t) = \point{e} + t\direction{d}, \text{ with } t \in \rangeZeroInf \]
infinite plane
infinite plane
- \(\tilde\p \in \text{plane} \iff (\tilde\p - \tilde\c) \* \hat\n = 0 \iff \tilde\p \* \hat\n = d\)
- note: last eqn slightly abuses notation
- \(\tilde\p(u,v) = \tilde\c + u \* \hat\u + v \* \hat\v\) with \((u,v) \in (-\infty,\infty)^2\)
- normal: \(\hat\n = \hat\u \xx \hat\v\)
triangle
triangle baricentric coordinates
- \(\tilde\p(\alpha,\beta,\gamma) = \alpha \tilde\a + \beta \tilde\b + \gamma \tilde\c\) with \(\alpha + \beta + \gamma = 1\)
- note: slightly abuses notation
- \(\tilde\p(\alpha,\beta) = \alpha (\tilde\a-\tilde\c) + \beta (\tilde\b-\tilde\c) + \tilde\c\)
- \(\alpha = \mathit{area}\left( \tilde\b\tilde\c\tilde\p \right) / \mathit{area}\left( \tilde\a\tilde\b\tilde\c \right)\), ...
sphere
sphere
- \(\tilde\p \in \text{sphere} \iff || \tilde\p-\tilde\c || = r\)
- \(\tilde\p(\theta,\phi) = \tilde\c + r \* \left( \cos \phi \sin \theta, \sin \phi \sin \theta, \cos \theta \right)\)
geometry crash course / review
frames
frame
coordinate system (aka frame)
\[
\frame{f}_{2D} = \{ \point{f}_o, \direction{f}_x, \direction{f}_y \} \qquad
\frame{f}_{3D} = \{ \point{f}_o, \direction{f}_x, \direction{f}_y, \direction{f}_z \}
\]
- \(\point{f}_o\): position, called "origin"
- \(\direction{f}_x\), \(\direction{f}_y\), \(\direction{f}_z\): orthonormal axes
- default (or world) frame: origin at \((0,0,0)\) and three major axes
frame
point coords and vector coords are defined wrt a frame
- \(\tilde\p=(p_x,p_y,p_z)\) wrt \(\{\tilde\f_o,\hat\f_x,\hat\f_y,\hat\f_z\}\) (world if not specified)
changing frames
change of coordinate system from world (\(\frame{f}\)) to local (\(\frame{f}'\))
- general: transform \(\frame{f} \rightarrow \frame{f}'\), where \(\frame{f}'\) is defined wrt to \(\frame{f}\)
- \(\point{p} = (p_x, p_y, p_z)\) is defined wrt to \(\frame{f}\)
- find equivalent \(\point{p}' = (p'_x, p'_y, p'_z)\), defined wrt to \(\frame{f}'\)
- \(\point{p}' = \left( (\point{p} - \point{f}'_o) \* \direction{f}'_x, (\point{p} - \point{f}'_o) \* \direction{f}'_y, (\point{p} - \point{f}'_o) \* \direction{f}'_z \right)\)
 |
⇒ |
 |
changing frames
change of coordinate system from local (\(\frame{f}'\)) to world (\(\frame{f}\))
- general: transform \(\frame{f}' \rightarrow \frame{f}\), where \(\frame{f}'\) is defined wrt to \(\frame{f}\)
- \(\tilde\p' = (p'_x, p'_y, p'_z)\) is defined wrt to \(\frame{f}'\)
- find equivalent \(\tilde\p = (p_x, p_y, p_z)\), defined wrt to \(\frame{f}\)
- \(\tilde\p = \tilde\f'_o + p'_x \hat\f'_x + p'_y \hat\f'_y + p'_z \hat\f'_z\)
 |
⇐ |
 |
changing frames
vector coords are defined wrt a frame
- assuming \(\frame{f}'\) is defined wrt to \(\frame{f}\)
- to change coord system, ignore origin
- \(\v = v'_x \hat\f'_x + v'_y \hat\f'_y + v'_z \hat\f'_z\)
- \(\v' = \left( \v \* \hat\f'_x, \v \* \hat\f'_y, \v \* \hat\f'_z \right)\)
direction coords are defined wrt a frame
- same as vector
- normalize afterwards to help reduce numerical errors
constructing frames
construct a frame from two arbitrary vectors \(\x'\), \(\y'\)
- assume that \(\x'\) is not parallel to \(\y'\)
- \(\hat\x = \normalize{\x'}\)
- \(\hat\z = \normalize{\x' \xx \hat\y}\)
- \(\hat\y = \hat\z \xx \hat\x\)
construct a frame from an arbitrary vector \(\z'\)
- pick a random direction \(\hat\v\) not parallel to \(\z'\)
- \(\hat\x = \normalize{\v \xx \z'}\)
- \(\hat\y = \normalize{\z' \xx \hat\x}\)
- \(\hat\z = \normalize{\z'}\)
frame hierarchy
all frames are defined wrt to other frames (except world is defined wrt to itself)
- produces a hierarchy of frames
- useful for:
objects with local frame
maths simplify to elegant equations when surfaces (ex: planes, triangles, spheres) are defined wrt a local coordinate system
transform surface to use frame
-
set \(\tilde\f_o\) to the "center" of the surface (\(\tilde\c\))
- surface center is now at the origin
- \(\tilde\c = 0\)
-
set \(\hat\f_x\),\(\hat\f_y\),\(\hat\f_z\) to \(\hat\u\),\(\hat\v\),\(\hat\n\)
- \(\hat\u\),\(\hat\v\),\(\hat\n\) now aligned to major axes
- \(\hat\u = (1,0,0)\), \(\hat\v = (0,1,0)\), \(\hat\n = (0,0,1)\)