Introduction to Computer Graphics CS 445 / 645 Lecture 10 Chapter 7: Transformations Gimbal.

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Three Dimensional Modeling Transformations
MAE152 Computer Graphicsfor Scientists and Engineers Revision of Matrices Relevance to Graphics.
Computer Graphics Recitation 2. 2 The plan today Learn about rotations in 2D and 3D. Representing rotations by quaternions.
3D Coordinate Systems and Transformations Revision 1
3D orientation.
CSCE 689: Computer Animation Rotation Representation and Interpolation
CSCE 441: Computer Graphics Rotation Representation and Interpolation
CSCE 641: Computer Graphics Rotation Representation and Interpolation Jinxiang Chai.
Computer Graphics (Fall 2008) COMS 4160, Lecture 3: Transformations 1
Rotation representation and Interpolation
Computer Graphics (Fall 2004) COMS 4160, Lecture 3: Transformations 1
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by Greg Humphreys)
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Technical Background.
CS 445 / 645 Introduction to Computer Graphics Lecture 21 Representing Rotations Lecture 21 Representing Rotations.
10/5/04© University of Wisconsin, CS559 Fall 2004 Last Time Compositing Painterly Rendering Intro to 3D Graphics Homework 3 due Oct 12 in class.
CS 450: COMPUTER GRAPHICS 3D TRANSFORMATIONS SPRING 2015 DR. MICHAEL J. REALE.
Computer Vision Group Prof. Daniel Cremers Autonomous Navigation for Flying Robots Lecture 3.1: 3D Geometry Jürgen Sturm Technische Universität München.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 3: Transformations 1
1 Kinematics ( 運動學 ) Primer Jyun-Ming Chen Fall 2009.
HCT.
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
3D Kinematics Consists of two parts 3D rotation 3D translation  The same as 2D 3D rotation is more complicated than 2D rotation (restricted to z- axis)
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Computer Graphics (fall 2009)
Computer Graphics Bing-Yu Chen National Taiwan University.
3D Computer Graphics An oh so brief introduction.
Rotations and Translations
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
1 CS 430/536 Computer Graphics I 3D Transformations World Window to Viewport Transformation Week 2, Lecture 4 David Breen, William Regli and Maxim Peysakhov.
Advanced Computer Graphics Spring 2014
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Rotations and Quaternions Week 9, Wed 29 Oct 2003.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Jinxiang Chai Composite Transformations and Forward Kinematics 0.
Geometric Objects and Transformation
10/3/02 (c) 2002 University of Wisconsin, CS 559 Last Time 2D Coordinate systems and transformations.
CS 445 / 645 Introduction to Computer Graphics Lecture 5 Assignment 1 3D Primitives and Transformations Lecture 5 Assignment 1 3D Primitives and Transformations.
CS 551/645 Fall 2000 Parameterized Rotations, Curves, and Surfaces.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
CS 551/651 Advanced Graphics Technical Background.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Projections Angel: Interactive Computer Graphics.
Transformations: Projection CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 3: Transformations 1
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
Euler Angles This means, that we can represent an orientation with 3 numbers Assuming we limit ourselves to 3 rotations without successive rotations about.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Computer Graphics I, Fall 2010 Transformations.
Week 5 - Monday.  What did we talk about last time?  Lines and planes  Trigonometry  Transforms  Affine transforms  Rotation  Scaling  Shearing.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
Fundamentals of Computer Animation Orientation and Rotation.
Transformations Review 4/18/2018 ©Babu 2009.
Rendering Pipeline Fall, 2015.
CPSC 641: Computer Graphics Rotation Representation and Interpolation
CS 445 / 645 Introduction to Computer Graphics
COMPUTER GRAPHICS CHAPTERS CS 482 – Fall 2017 TRANSFORMATIONS
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
Rotations and Quaternions Week 9, Wed 29 Oct 2003
UMBC Graphics for Games
CSCE441: Computer Graphics 2D/3D Transformations
VIRTUAL ENVIRONMENT.
Presentation transcript:

Introduction to Computer Graphics CS 445 / 645 Lecture 10 Chapter 7: Transformations Gimbal

Overview Rotation representations EulerEuler Axis-angleAxis-angle QuaternionQuaternion Camera Transformations ProjectionsProjections Rotation representations EulerEuler Axis-angleAxis-angle QuaternionQuaternion Camera Transformations ProjectionsProjections

Basic 3D Transformations Rotate around Z axis: Rotate around Y axis: Rotate around X axis:

3-D Rotation General rotations in 3-D require rotating about an arbitrary axis of rotation Deriving the rotation matrix for such a rotation directly is a good exercise in linear algebra Standard approach: express general rotation as composition of canonical rotations Rotations about X, Y, ZRotations about X, Y, Z General rotations in 3-D require rotating about an arbitrary axis of rotation Deriving the rotation matrix for such a rotation directly is a good exercise in linear algebra Standard approach: express general rotation as composition of canonical rotations Rotations about X, Y, ZRotations about X, Y, Z

Composing Canonical Rotations Goal: rotate about arbitrary vector A by  Idea: we know how to rotate about X,Y,ZIdea: we know how to rotate about X,Y,Z –So, rotate about Y by  until A lies in the YZ plane –Then rotate about X by  until A coincides with +Z –Then rotate about Z by  –Then reverse the rotation about X (by -  ) –Then reverse the rotation about Y (by -  ) Goal: rotate about arbitrary vector A by  Idea: we know how to rotate about X,Y,ZIdea: we know how to rotate about X,Y,Z –So, rotate about Y by  until A lies in the YZ plane –Then rotate about X by  until A coincides with +Z –Then rotate about Z by  –Then reverse the rotation about X (by -  ) –Then reverse the rotation about Y (by -  )

Composing Canonical Rotations First: rotating about Y by  until A lies in YZ How exactly do we calculate  ? Project A onto XZ plane (Throw away y-coordinate)Project A onto XZ plane (Throw away y-coordinate) Find angle  that rotates A to x-axis:Find angle  that rotates A to x-axis:  = -(90° -  ) =  - 90 ° Second: rotating about x-axis by  until A lies on z-axis How do we calculate  ? First: rotating about Y by  until A lies in YZ How exactly do we calculate  ? Project A onto XZ plane (Throw away y-coordinate)Project A onto XZ plane (Throw away y-coordinate) Find angle  that rotates A to x-axis:Find angle  that rotates A to x-axis:  = -(90° -  ) =  - 90 ° Second: rotating about x-axis by  until A lies on z-axis How do we calculate  ?

Composing Matrices So we have the following matrices: p: The point to be rotated about A by p: The point to be rotated about A by  R y  : Rotate about Y by R y  : Rotate about Y by  R x  : Rotate about X by R x  : Rotate about X by  R z  : Rotate about Z by R z  : Rotate about Z by  R x  -1 : Undo rotation about X by R x  -1 : Undo rotation about X by  R y  -1 : Undo rotation about Y by R y  -1 : Undo rotation about Y by  In what order should we multiply them? So we have the following matrices: p: The point to be rotated about A by p: The point to be rotated about A by  R y  : Rotate about Y by R y  : Rotate about Y by  R x  : Rotate about X by R x  : Rotate about X by  R z  : Rotate about Z by R z  : Rotate about Z by  R x  -1 : Undo rotation about X by R x  -1 : Undo rotation about X by  R y  -1 : Undo rotation about Y by R y  -1 : Undo rotation about Y by  In what order should we multiply them?

Compositing Matrices Short answer: the transformations, in order, are written from right to left In other words, the first matrix to affect the vector goes next to the vector, the second next to the first, etc.In other words, the first matrix to affect the vector goes next to the vector, the second next to the first, etc. So in our case: p’ = R y  -1 R x  -1 R z  R x  R y  p Short answer: the transformations, in order, are written from right to left In other words, the first matrix to affect the vector goes next to the vector, the second next to the first, etc.In other words, the first matrix to affect the vector goes next to the vector, the second next to the first, etc. So in our case: p’ = R y  -1 R x  -1 R z  R x  R y  p

Rotation Matrices Notice these two matrices: R x  : Rotate about X by  R x  -1 : Undo rotation about X by  How can we calculate R x  -1 ? Notice these two matrices: R x  : Rotate about X by  R x  -1 : Undo rotation about X by  How can we calculate R x  -1 ?

Rotation Matrices Notice these two matrices: R x  : Rotate about X by  R x  -1 : Undo rotation about X by  How can we calculate R x  -1 ? Obvious answer: calculate R x (-  )Obvious answer: calculate R x (-  ) Clever answer: exploit fact that rotation matrices are orthonormalClever answer: exploit fact that rotation matrices are orthonormal Notice these two matrices: R x  : Rotate about X by  R x  -1 : Undo rotation about X by  How can we calculate R x  -1 ? Obvious answer: calculate R x (-  )Obvious answer: calculate R x (-  ) Clever answer: exploit fact that rotation matrices are orthonormalClever answer: exploit fact that rotation matrices are orthonormal

Rotation Matrices Notice these two matrices: R x  : Rotate about X by  R x  -1 : Undo rotation about X by  How can we calculate R x  -1 ? Obvious answer: calculate R x (-  )Obvious answer: calculate R x (-  ) Clever answer: exploit fact that rotation matrices are orthonormalClever answer: exploit fact that rotation matrices are orthonormal What is an orthonormal matrix? What property are we talking about? Notice these two matrices: R x  : Rotate about X by  R x  -1 : Undo rotation about X by  How can we calculate R x  -1 ? Obvious answer: calculate R x (-  )Obvious answer: calculate R x (-  ) Clever answer: exploit fact that rotation matrices are orthonormalClever answer: exploit fact that rotation matrices are orthonormal What is an orthonormal matrix? What property are we talking about?

Rotation Matrices Orthonormal matrix: orthogonal (columns/rows linearly independent)orthogonal (columns/rows linearly independent) normalized (columns/rows length of 1)normalized (columns/rows length of 1) The inverse of an orthogonal matrix is just its transpose: Orthonormal matrix: orthogonal (columns/rows linearly independent)orthogonal (columns/rows linearly independent) normalized (columns/rows length of 1)normalized (columns/rows length of 1) The inverse of an orthogonal matrix is just its transpose:

Representing 3 Rotational DOFs 3x3 Matrix (9 DOFs) Rows of matrix define orthogonal axesRows of matrix define orthogonal axes Euler Angles (3 DOFs) Rot x + Rot y + Rot zRot x + Rot y + Rot z Axis-angle (4 DOFs) Axis of rotation + Rotation amountAxis of rotation + Rotation amount Quaternion (4 DOFs) 4 dimensional complex numbers4 dimensional complex numbers 3x3 Matrix (9 DOFs) Rows of matrix define orthogonal axesRows of matrix define orthogonal axes Euler Angles (3 DOFs) Rot x + Rot y + Rot zRot x + Rot y + Rot z Axis-angle (4 DOFs) Axis of rotation + Rotation amountAxis of rotation + Rotation amount Quaternion (4 DOFs) 4 dimensional complex numbers4 dimensional complex numbers

Rotation Matrices What did we start with? 3 rotations (roll, pitch, yaw)3 rotations (roll, pitch, yaw) –Three numbers –Called Euler Angles Axis-angleAxis-angle –Four numbers And we end up with a 4x4 transformation matrix Where inner 3x3 describes rotationWhere inner 3x3 describes rotation What did we start with? 3 rotations (roll, pitch, yaw)3 rotations (roll, pitch, yaw) –Three numbers –Called Euler Angles Axis-angleAxis-angle –Four numbers And we end up with a 4x4 transformation matrix Where inner 3x3 describes rotationWhere inner 3x3 describes rotation

Really, a whole matrix to represent three numbers? Underconstrained? 9 DOFs must reduce to 3 Rows must be unit length (-3 DOFs) Rows must be orthogonal (-3 DOFs) Drifting matrices is very bad Numerical errors results when trying to gradually rotate matrix by adding derivativesNumerical errors results when trying to gradually rotate matrix by adding derivatives Resulting matrix may scale / shearResulting matrix may scale / shear Gram-Schmidt algorithm will re-orthogonalize your matrixGram-Schmidt algorithm will re-orthogonalize your matrix Difficult to interpolate between matrices Why would we do this?Why would we do this? 9 DOFs must reduce to 3 Rows must be unit length (-3 DOFs) Rows must be orthogonal (-3 DOFs) Drifting matrices is very bad Numerical errors results when trying to gradually rotate matrix by adding derivativesNumerical errors results when trying to gradually rotate matrix by adding derivatives Resulting matrix may scale / shearResulting matrix may scale / shear Gram-Schmidt algorithm will re-orthogonalize your matrixGram-Schmidt algorithm will re-orthogonalize your matrix Difficult to interpolate between matrices Why would we do this?Why would we do this?

Euler Angles (  x,  y,  z ) = R z R y R x Rotate  x degrees about x-axisRotate  x degrees about x-axis Rotate  y degrees about y-axisRotate  y degrees about y-axis Rotate  z degrees about z-axisRotate  z degrees about z-axis Axis order is not defined (y, z, x), (x, z, y), (z, y, x)… are all legal(y, z, x), (x, z, y), (z, y, x)… are all legal Pick onePick one (  x,  y,  z ) = R z R y R x Rotate  x degrees about x-axisRotate  x degrees about x-axis Rotate  y degrees about y-axisRotate  y degrees about y-axis Rotate  z degrees about z-axisRotate  z degrees about z-axis Axis order is not defined (y, z, x), (x, z, y), (z, y, x)… are all legal(y, z, x), (x, z, y), (z, y, x)… are all legal Pick onePick one

Euler Angles Rotations not uniquely defined ex: (z, x, y) = (90, 45, 45) = (45, 0, -45) takes positive x-axis to (1, 1, 1)ex: (z, x, y) = (90, 45, 45) = (45, 0, -45) takes positive x-axis to (1, 1, 1) Cartesian coordinates are independent of one another, but Euler angles are notCartesian coordinates are independent of one another, but Euler angles are not Gimbal Lock Term derived from mechanical problem that arises in gimbal mechanism that supports a compass or a gyroTerm derived from mechanical problem that arises in gimbal mechanism that supports a compass or a gyro Rotations not uniquely defined ex: (z, x, y) = (90, 45, 45) = (45, 0, -45) takes positive x-axis to (1, 1, 1)ex: (z, x, y) = (90, 45, 45) = (45, 0, -45) takes positive x-axis to (1, 1, 1) Cartesian coordinates are independent of one another, but Euler angles are notCartesian coordinates are independent of one another, but Euler angles are not Gimbal Lock Term derived from mechanical problem that arises in gimbal mechanism that supports a compass or a gyroTerm derived from mechanical problem that arises in gimbal mechanism that supports a compass or a gyro

A Gimbal Hardware implementation of Euler angles (used for mounting gyroscopes and globes)

Gimbal Lock

Occurs when two axes are aligned Second and third rotations have effect of transforming earlier rotations ex: Rot x, Rot y, Rot zex: Rot x, Rot y, Rot z –If Rot y = 90 degrees, Rot z == -Rot x Occurs when two axes are aligned Second and third rotations have effect of transforming earlier rotations ex: Rot x, Rot y, Rot zex: Rot x, Rot y, Rot z –If Rot y = 90 degrees, Rot z == -Rot x

Gimbal Lock

Interpolation Interpolation between two Euler angles is not unique ex: (x, y, z) rotation (0, 0, 0) to (180, 0, 0) vs. (0, 0, 0) to (0, 180, 180)(0, 0, 0) to (180, 0, 0) vs. (0, 0, 0) to (0, 180, 180) Interpolation about different axes are not independentInterpolation about different axes are not independent Interpolation between two Euler angles is not unique ex: (x, y, z) rotation (0, 0, 0) to (180, 0, 0) vs. (0, 0, 0) to (0, 180, 180)(0, 0, 0) to (180, 0, 0) vs. (0, 0, 0) to (0, 180, 180) Interpolation about different axes are not independentInterpolation about different axes are not independent

Interpolation

Axis-angle Notation Define an axis of rotation (x, y, z) and a rotation about that axis,  R( , n) 4 degrees of freedom specify 3 rotational degrees of freedom because axis of rotation is constrained to be a unit vector Define an axis of rotation (x, y, z) and a rotation about that axis,  R( , n) 4 degrees of freedom specify 3 rotational degrees of freedom because axis of rotation is constrained to be a unit vector

Axis-angle Rotation r r’ n Given r – Vector in space to rotate n – Unit-length axis in space about which to rotate  – The amount about n to rotate Solve r’ – The rotated vector

Axis-angle Rotation Step 1 Compute r k an extended version of the rotation axis, nCompute r k an extended version of the rotation axis, n r k = (n ¢ r) nr k = (n ¢ r) n Step 1 Compute r k an extended version of the rotation axis, nCompute r k an extended version of the rotation axis, n r k = (n ¢ r) nr k = (n ¢ r) n r r’ rkrk

Axis-angle Rotation Compute r ? r ? = r – (n ¢ r) n Compute r ? r ? = r – (n ¢ r) n r r’ r?r?

Axis-angle Rotation Compute v, a vector perpendicular to r k and r ? v = r k £ r ? Use v and r ? and  to compute r’ Compute v, a vector perpendicular to r k and r ? v = r k £ r ? Use v and r ? and  to compute r’ v  cos(  ) r ? + sin(  ) v r?r?

Axis-angle Notation r RrRr n  r par = (n.r) n r perp = r – (n.r) n V = n x (r – (n.r) n) = n x r Rr = Rr par + Rr perp = Rr par + (cos  ) r perp + (sin  ) V =(n.r) n + cos  (r – (n.r)n) + (sin  ) n x r = (cos  )r + (1 – cos  ) n (n.r) + (sin  ) n x r

Axis-angle Notation No easy way to determine how to concatenate many axis-angle rotations that result in final desired axis-angle rotation No simple way to interpolate rotations No easy way to determine how to concatenate many axis-angle rotations that result in final desired axis-angle rotation No simple way to interpolate rotations

Quaternion Remember complex numbers: a + ib Where i 2 = -1Where i 2 = -1 Invented by Sir William Hamilton (1843) Remember Hamiltonian path from Discrete II?Remember Hamiltonian path from Discrete II?Quaternion: Q = a + bi + cj + dkQ = a + bi + cj + dk –Where i 2 = j 2 = k 2 = -1 and ij = k and ji = -k Represented as: q = (s, v) = s + v x i + v y j + v z kRepresented as: q = (s, v) = s + v x i + v y j + v z k Remember complex numbers: a + ib Where i 2 = -1Where i 2 = -1 Invented by Sir William Hamilton (1843) Remember Hamiltonian path from Discrete II?Remember Hamiltonian path from Discrete II?Quaternion: Q = a + bi + cj + dkQ = a + bi + cj + dk –Where i 2 = j 2 = k 2 = -1 and ij = k and ji = -k Represented as: q = (s, v) = s + v x i + v y j + v z kRepresented as: q = (s, v) = s + v x i + v y j + v z k

Quaternion A quaternion is a 4-D unit vector q = [x y z w] It lies on the unit hypersphere x 2 + y 2 + z 2 + w 2 = 1It lies on the unit hypersphere x 2 + y 2 + z 2 + w 2 = 1 For rotation about (unit) axis v by angle  vector part = (sin  /2) v = [x y z]vector part = (sin  /2) v = [x y z] scalar part = (cos  /2) = wscalar part = (cos  /2) = w (sin(  /2) v x, sin(  /2) v y, sin(  /2) v z, cos (  /2))(sin(  /2) v x, sin(  /2) v y, sin(  /2) v z, cos (  /2)) Only a unit quaternion encodes a rotation - normalize A quaternion is a 4-D unit vector q = [x y z w] It lies on the unit hypersphere x 2 + y 2 + z 2 + w 2 = 1It lies on the unit hypersphere x 2 + y 2 + z 2 + w 2 = 1 For rotation about (unit) axis v by angle  vector part = (sin  /2) v = [x y z]vector part = (sin  /2) v = [x y z] scalar part = (cos  /2) = wscalar part = (cos  /2) = w (sin(  /2) v x, sin(  /2) v y, sin(  /2) v z, cos (  /2))(sin(  /2) v x, sin(  /2) v y, sin(  /2) v z, cos (  /2)) Only a unit quaternion encodes a rotation - normalize

Quaternion Rotation matrix corresponding to a quaternion: [x y z w] =[x y z w] = Quaternion Multiplication q 1 * q 2 = [v 1, w 1 ] * [v 2, w 2 ] = [(w 1 v 2 +w 2 v 1 + (v 1 x v 2 )), w 1 w 2 -v 1.v 2 ]q 1 * q 2 = [v 1, w 1 ] * [v 2, w 2 ] = [(w 1 v 2 +w 2 v 1 + (v 1 x v 2 )), w 1 w 2 -v 1.v 2 ] quaternion * quaternion = quaternionquaternion * quaternion = quaternion this satisfies requirements for mathematical groupthis satisfies requirements for mathematical group Rotating object twice according to two different quaternions is equivalent to one rotation according to product of two quaternionsRotating object twice according to two different quaternions is equivalent to one rotation according to product of two quaternions Rotation matrix corresponding to a quaternion: [x y z w] =[x y z w] = Quaternion Multiplication q 1 * q 2 = [v 1, w 1 ] * [v 2, w 2 ] = [(w 1 v 2 +w 2 v 1 + (v 1 x v 2 )), w 1 w 2 -v 1.v 2 ]q 1 * q 2 = [v 1, w 1 ] * [v 2, w 2 ] = [(w 1 v 2 +w 2 v 1 + (v 1 x v 2 )), w 1 w 2 -v 1.v 2 ] quaternion * quaternion = quaternionquaternion * quaternion = quaternion this satisfies requirements for mathematical groupthis satisfies requirements for mathematical group Rotating object twice according to two different quaternions is equivalent to one rotation according to product of two quaternionsRotating object twice according to two different quaternions is equivalent to one rotation according to product of two quaternions

Quaternion Example X-roll of  (cos (  /2), sin (  /2) (1, 0, 0)) = (0, (1, 0, 0))(cos (  /2), sin (  /2) (1, 0, 0)) = (0, (1, 0, 0)) Y-roll 0f  (0, (0, 1, 0))(0, (0, 1, 0)) Z-roll of  (0, (0, 0, 1))(0, (0, 0, 1)) R y (  ) followed by R z (  ) (0, (0, 1, 0) times (0, (0, 0, 1)) = (0, (0, 1, 0) x (0, 0, 1) = (0, (1, 0, 0))(0, (0, 1, 0) times (0, (0, 0, 1)) = (0, (0, 1, 0) x (0, 0, 1) = (0, (1, 0, 0)) X-roll of  (cos (  /2), sin (  /2) (1, 0, 0)) = (0, (1, 0, 0))(cos (  /2), sin (  /2) (1, 0, 0)) = (0, (1, 0, 0)) Y-roll 0f  (0, (0, 1, 0))(0, (0, 1, 0)) Z-roll of  (0, (0, 0, 1))(0, (0, 0, 1)) R y (  ) followed by R z (  ) (0, (0, 1, 0) times (0, (0, 0, 1)) = (0, (0, 1, 0) x (0, 0, 1) = (0, (1, 0, 0))(0, (0, 1, 0) times (0, (0, 0, 1)) = (0, (0, 1, 0) x (0, 0, 1) = (0, (1, 0, 0))

Quaternion Interpolation Biggest advantage of quaternions InterpolationInterpolation Cannot linearly interpolate between two quaternions because it would speed up in middleCannot linearly interpolate between two quaternions because it would speed up in middle Instead, Spherical Linear Interpolation, slerp()Instead, Spherical Linear Interpolation, slerp() Used by modern video games for third-person perspectiveUsed by modern video games for third-person perspective Why?Why? Biggest advantage of quaternions InterpolationInterpolation Cannot linearly interpolate between two quaternions because it would speed up in middleCannot linearly interpolate between two quaternions because it would speed up in middle Instead, Spherical Linear Interpolation, slerp()Instead, Spherical Linear Interpolation, slerp() Used by modern video games for third-person perspectiveUsed by modern video games for third-person perspective Why?Why?

SLERP Quaternion is a point on the 4-D unit sphere interpolating rotations requires a unit quaternion at each stepinterpolating rotations requires a unit quaternion at each step –another point on the 4-D unit sphere move with constant angular velocity along the great circle between two pointsmove with constant angular velocity along the great circle between two points –A great circle is a section of a sphere that contains a diameter of the sphere (Kern and Bland 1948, p. 87). Any rotation is defined by 2 quaternions, so pick the shortest SLERP To interpolate more than two points, solve a non-linear variational constrained optimization Ken Shoemake in SIGGRAPH ’85 ( Shoemake in SIGGRAPH ’85 ( Quaternion is a point on the 4-D unit sphere interpolating rotations requires a unit quaternion at each stepinterpolating rotations requires a unit quaternion at each step –another point on the 4-D unit sphere move with constant angular velocity along the great circle between two pointsmove with constant angular velocity along the great circle between two points –A great circle is a section of a sphere that contains a diameter of the sphere (Kern and Bland 1948, p. 87). Any rotation is defined by 2 quaternions, so pick the shortest SLERP To interpolate more than two points, solve a non-linear variational constrained optimization Ken Shoemake in SIGGRAPH ’85 ( Shoemake in SIGGRAPH ’85 (

Quaternion Interpolation Quaternion (white) vs. Euler (black) interpolation Left images are linear interpolation Right images are cubic interpolation Quaternion (white) vs. Euler (black) interpolation Left images are linear interpolation Right images are cubic interpolation

Quaternion Code /quaternions_01.htm Registration requiredRegistration required Camera control code –File, gltb.c –gltbMatrix and gltbMotion /quaternions_01.htm Registration requiredRegistration required Camera control code –File, gltb.c –gltbMatrix and gltbMotion

3D Rendering Pipeline (for direct illumination) Modeling Transformation Modeling Transformation Viewing Transformation Viewing Transformation Projection Transformation Projection Transformation Lighting 3D Geometric Primitives Image Clipping Scan Conversion Scan Conversion Transform into 3D world coordinate system Transform into 3D camera coordinate system Draw pixels (includes texturing, hidden surface,...) Clip primitives outside camera’s view Transform into 2D screen coordinate system Illuminate according to lighting and reflectance

Reminder: Homogeneous Coords What effect does the following matrix have? Conceptually, the fourth coordinate w is a bit like a scale factor What effect does the following matrix have? Conceptually, the fourth coordinate w is a bit like a scale factor

Homogenous Coordinates Increasing w makes things smaller We think of homogenous coordinates as defining a projective space Increasing w  “getting further away”Increasing w  “getting further away” Will come in handy for projection matrices Increasing w makes things smaller We think of homogenous coordinates as defining a projective space Increasing w  “getting further away”Increasing w  “getting further away” Will come in handy for projection matrices

Projection Matrix We talked about geometric transforms, focusing on modeling transforms Ex: translation, rotation, scale, gluLookAt()Ex: translation, rotation, scale, gluLookAt() These are encapsulated in the OpenGL modelview matrixThese are encapsulated in the OpenGL modelview matrix Projection is also represented as a matrix Next few slides: representing orthographic and perspective projection with the projection matrix We talked about geometric transforms, focusing on modeling transforms Ex: translation, rotation, scale, gluLookAt()Ex: translation, rotation, scale, gluLookAt() These are encapsulated in the OpenGL modelview matrixThese are encapsulated in the OpenGL modelview matrix Projection is also represented as a matrix Next few slides: representing orthographic and perspective projection with the projection matrix

Taxonomy of Projections FVFHP Figure 6.10

Taxonomy of Projections

Parallel Projection Angel Figure 5.4 Center of projection is at infinity Direction of projection (DOP) same for all pointsDirection of projection (DOP) same for all points Center of projection is at infinity Direction of projection (DOP) same for all pointsDirection of projection (DOP) same for all points DOP View Plane

Orthographic Projections Angel Figure 5.5 TopSide Front DOP perpendicular to view plane

Oblique Projections H&B Figure DOP not perpendicular to view plane Cavalier (DOP  = 45 o ) Cabinet (DOP  = 63.4 o )

Orthographic Projection Simple Orthographic Transformation Original world units are preserved Pixel units are preferredPixel units are preferred Simple Orthographic Transformation Original world units are preserved Pixel units are preferredPixel units are preferred

Orthographic: Screen Space Transformation top=20 m bottom=10 m left =10 mright = 20 m (0, 0) (max pix x, max pix y ) (width in pixels) (height in pixels)

Orthographic: Screen Space Transformation left, right, top, bottom refer to the viewing frustum in modeling coordinates width and height are in pixel units This matrix scales and translates to accomplish the transition in units left, right, top, bottom refer to the viewing frustum in modeling coordinates width and height are in pixel units This matrix scales and translates to accomplish the transition in units