- Forward


Transformation of 3D Shapes
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Motivation
Back SMYC Forward
  • What We Have:
    • Methods for representing lines, triangles, and convex polygons in 2D and 3D
    • The ability to transform 2D shapes
  • What We Need:
    • The ability to transform 3D shapes in various ways
Coordinate Systems
Back SMYC Forward
  • In 2D:
    • We considered scaling, reflection, shear, rotation and translation in both Cartesian and homogeneous coordinates
  • In 3D:
    • We could consider both Cartesian and homogeneous coordinates but we will only consider homogeneous coordinates
Remember
Back SMYC Forward
  • This discussion assumes that we are using column vectors
  • If you implement using row vectors then you will need to reverse the order of the operations
Visualization
Back SMYC Forward
  • As we have seen, it can be useful to visualize these kinds of operations
  • Unfortunately, we can't draw figures in three dimensions (we have to project onto two)
  • This can cause misconceptions so it is better to use physical models and not drawings
Translation
Back SMYC Forward
  • Translation Matrix:
    • \( \bs{T} = \left[ \begin{array}{c c c c} 1 & 0 & 0 & \tau_{1} \\ 0 & 1 & 0 & \tau_{2} \\ 0 & 0 & 1 & \tau_{3} \\ 0 & 0 & 0 & 1 \end{array} \right] \)
  • Inverse Translation Matrix:
    • \( \bs{T}^{-1} = \left[ \begin{array}{c c c c} 1 & 0 & 0 & -\tau_{1} \\ 0 & 1 & 0 & -\tau_{2} \\ 0 & 0 & 1 & -\tau_{3} \\ 0 & 0 & 0 & 1 \end{array} \right] \)
Scaling
Back SMYC Forward
  • Scaling Matrix:
    • \( \bs{S} = \left[ \begin{array}{c c c c} \sigma_{1} & 0 & 0 & 0 \\ 0 & \sigma_{2} & 0 & 0 \\ 0 & 0 & \sigma_{3} & 0 \\ 0 & 0 & 0 & 1 \end{array} \right] \)
  • Inverse Scaling Matrix:
    • \( \bs{S}^{-1} = \left[ \begin{array}{c c c c} 1/\sigma_{1} & 0 & 0 & 0 \\ 0 & 1/\sigma_{2} & 0 & 0 \\ 0 & 0 & 1/\sigma_{3} & 0 \\ 0 & 0 & 0 & 1 \end{array} \right] \)
Rotation Around Axes
Back SMYC Forward
  • Rotation Around the \(x\)-Axis:
    • \( \bs{R_{x}} = \left[ \begin{array}{c c c c} 1 & 0 & 0 & 0 \\ 0 & \cos \phi & - \sin \phi & 0 \\ 0 & \sin \phi & \cos \phi & 0 \\ 0 & 0 & 0 & 1 \end{array} \right] \)
  • Rotation Around the \(y\)-Axis:
    • \( \bs{R_{y}} = \left[ \begin{array}{c c c c} \cos \theta & 0 & \sin \theta & 0 \\ 0 & 1 & 0 & 0 \\ - \sin \theta & 0 & \cos \theta & 0 \\ 0 & 0 & 0 & 1 \end{array} \right] \)
  • Rotation Around the \(z\)-Axis:
    • \( \bs{R_{z}} = \left[ \begin{array}{c c c c} \cos \psi & - \sin \psi & 0 & 0 \\ \sin \psi & \cos \psi & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1\end{array} \right] \)
Rotation Around Axes (cont.)
Back SMYC Forward
  • Inverse Rotation Matrices:
    • Just rotate an equal amount in the opposite direction (e.g.,. replace \(\theta\) with \(- \theta\))
  • An Additional Result:
    • All of the \(\cos\) terms are on the diagonal and all of the \(\sin\) terms are off the diagonal
    • \(\cos(-\theta) = \cos \theta\)
    • \(\sin(-\theta) = - \sin \theta\)
    • So, \(\bs{R}^{-1} = \bs{R}^{T}\)
Shear
Back SMYC Forward
  • Defined:
    • A shear transforms the point \(\left[ \begin{array}{c c c c}x \\ y \\ z \\ 1\end{array} \right]\)
    • to the point \(\left[ \begin{array}{c c c c}x+ay+bz \\ cx+y+dz \\ ex+fy+z \\ 1\end{array} \right]\)
  • Shear Matrix:
    • \( \left[ \begin{array}{c c c c} 1 & a & b & 0 \\ c & 1 & d & 0 \\ e & f & 1 & 0 \\ 0 & 0 & 0 & 1\end{array} \right] \)
Concatenating Transforms
Back SMYC Forward
  • Sequential Transformations:
    • transformations-concatenation1
  • Being Careful About Dimensionality:
    • \(\bs{q} = \bs{A} \bs{p}\)
    • \(\bs{r} = \bs{B} \bs{q} = \bs{B} (\bs{A} \bs{p})\)
    • \(\bs{s} = \bs{C} \bs{r} = \bs{C} (\bs{B} \bs{q}) = \bs{C} (\bs{B} (\bs{A} \bs{p}))\)
Concatenating Transforms (cont.)
Back SMYC Forward
  • Associativity of Matrix Multiplication:
    • \(\bs{C} (\bs{B} (\bs{A} \bs{p})) = ((\bs{C} \bs{B}) \bs{A}) \bs{p}\)
  • The Concatenated Transform:
    • transformations-concatenation2
Complicated Rotations
Back SMYC Forward
  • Around the point \(\bs{p}\):
    • Translate by \(-\bs{p}\)
    • Rotate
    • Translate by \(\bs{p}\)
  • Rotation Around Multiple Axes:
    • \(\bs{R} = \bs{R_{x}} \bs{R_{y}} \bs{R_{z}}\)
  • Rotation Around a Line:
    • Combine the two above ideas
There's Always More to Learn
Back -