CSCE 441 Lecture 13

From Notes
Jump to navigation Jump to search

« previous | Wednesday, February 12, 2014 | next »


3D Transformations as Matrices

Rotation

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \begin{bmatrix} I & o \\ 0 & 1 \end{bmatrix} \, \begin{bmatrix} (1-\cos{\theta}) \, \vec{v} \, \vec{v}^T + \sin{\theta} \, (\vec{v} \times \_) + c \, I & 0 \\ 0 & 1 \end{bmatrix} \, \begin{bmatrix} I & -o \\ 0 & 1 \end{bmatrix} \, \begin{bmatrix} p \\ 1 \end{bmatrix} = \begin{bmatrix} \hat{p} \, 1 \end{bmatrix}}

Mirror Image

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \begin{bmatrix} I-2 \vec{v} \, \vec{v}^T & 2 \vec{v} \, \vec{v}^T \, o \\ 0 & 1 \end{bmatrix} \, \begin{bmatrix} p \\ 1 \end{bmatrix} = \begin{bmatrix} \hat{p} \\ 1 \end{bmatrix}}

Orthogonal Projection

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \begin{bmatrix} I-\vec{v} \, \vec{v}^T & \vec{v} \, \vec{v}^T \, o \\ 0 & 1 \end{bmatrix} \, \begin{bmatrix} p \\ 1 \end{bmatrix} = \begin{bmatrix} \hat{p} \\ 1 \end{bmatrix}}

Perspective Projection

Perspective transformations are not Affine!

Rational expressions require modification:

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \begin{bmatrix} \left( \vec{v}^T \, (e - o) \right) \, I - e \, \vec{v}^T & e \left( \vec{v}^T \, o \right) \\ -\vec{v}^T & \vec{v}^T \, e \end{bmatrix}}

homogeneous coordinates

In affine transformations, our matrix equation was

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \begin{bmatrix} L & t \\ 0 & 1 \end{bmatrix} \, \begin{bmatrix} p \\ 1 \end{bmatrix} = \begin{bmatrix} \hat{p} \\ 1 \end{bmatrix}}


Now we use

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \begin{bmatrix} L & t \\ c & d \end{bmatrix} \, \begin{bmatrix} p \\ 1 \end{bmatrix} = \begin{bmatrix} \hat{p} \\ \hat{w} \end{bmatrix}}

Where Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle c} and Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle d} represent the stuff in the denominator of the transformation equation

3D Location is Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \frac{\hat{p}}{\hat{w}}}

Note this equation still works for Affine transformations (where we divide by 1)

Hierarchical Animation

Multiple transformations at each joint of a skeleton.

For example, to move a point on the hand, we have to move the wrist (Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle M_1} ), elbow (Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle M_2} ), and shoulder (Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle M_3} ).

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \hat{p} = M_3 \, M_2 \, M_1 \, p }

In general,

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \hat{p} = \sum_j \alpha_j \, M_j \, p}


Transformations in OpenGL

4 types:

  • View
  • Model (put things in the scene)
  • Projection (takes 3D objects and projects onto a 2D surface)
  • Viewport

Commands:

  • glTranslatef(x,y,z)
  • glScalef(x,y,z)
  • glRotatef(theta, vx, vy, vz)
  • glLoadIdentity(void): replaces current matrix with identity matrix (i.e. removes current transformations)
  • glPushMatrix(void) and glPopMatrix(void): copies current matrix to new context and removes current matrix (respectively)


Order matters!

  • glTranslatef(0,1,3) = M[1]
  • glRotatef(45,0,1,0) = M[2]
  • glScalef(1,1,2) = M[3]

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle M_1 \, M_2 \, M_3 \, P}

OpenGL combines model and view matrix:

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle ModelView = V^{-1} \, M}

  1. push matrix
  2. specify viewer using inverse of view transformation (negative translation/rotation and in opposite order): Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \left( T \, R \right)^{-1} \, M = R^{-1} \, T^{-1} \, M}
  3. push matrix
  4. position objects with transformations in opposite order of what you would expect
  5. pop matrix
  6. repeat last 3 steps for each object in scene
  7. pop matrix


Special Matrix Commands

  • glMatrixMode(GL_MODELVIEW) and glMatrixMode(GL_PROJECTION)
  • gluLookAt(ex,ey,ez, cx,cy,cz, ux,uy,uz): set position of eye, direction of thing to look at, and the "up direction"
  • gluPerspective(fov, aspect, near, far)
  • glOrtho(left, right, bottom, top, near far) specify orthogonal projection
  • glViewport(x,y,w,h)