Introduction to Computer Graphics CS 445 / 645 Lecture 10 Chapter 7: TransformationsOverviewBasic 3D Transformations3-D RotationComposing Canonical RotationsSlide 6Composing MatricesCompositing MatricesRotation MatricesSlide 10Slide 11Slide 12Representing 3 Rotational DOFsSlide 14Really, a whole matrix to represent three numbers? Underconstrained?Euler AnglesSlide 17A GimbalGimbal LockSlide 20Slide 21InterpolationSlide 23Axis-angle NotationAxis-angle RotationSlide 26Slide 27Slide 28Slide 29Slide 30QuaternionSlide 32Slide 33Quaternion ExampleQuaternion InterpolationSLERPSlide 37Quaternion Code3D Rendering Pipeline (for direct illumination)Reminder: Homogeneous CoordsHomogenous CoordinatesProjection MatrixTaxonomy of ProjectionsSlide 44Parallel ProjectionOrthographic ProjectionsOblique ProjectionsOrthographic ProjectionOrthographic: Screen Space TransformationSlide 50Introduction to Computer GraphicsCS 445 / 645Lecture 10Chapter 7: TransformationsGimbalOverviewRotation representationsRotation representations•EulerEuler•Axis-angleAxis-angle•QuaternionQuaternionCamera TransformationsCamera Transformations•ProjectionsProjectionsRotation representationsRotation representations•EulerEuler•Axis-angleAxis-angle•QuaternionQuaternionCamera TransformationsCamera Transformations•ProjectionsProjectionsBasic 3D Transformationswzyxwzyx1000010000cossin00sincos'''Rotate around Z axis:wzyxwzyx10000cos0sin00100sin0cos'''Rotate around Y axis:wzyxwzyx10000cossin00sincos00001'''Rotate around X axis:3-D RotationGeneral rotations in 3-D require rotating about an General rotations in 3-D require rotating about an arbitraryarbitrary axis of rotationaxis of rotationDeriving the rotation matrix for such a rotation Deriving the rotation matrix for such a rotation directly is a good exercise in linear algebradirectly is a good exercise in linear algebraStandard approach: express general rotation as Standard approach: express general rotation as composition ofcomposition of canonical rotationscanonical rotations •Rotations about Rotations about X, Y, ZX, Y, ZGeneral rotations in 3-D require rotating about an General rotations in 3-D require rotating about an arbitraryarbitrary axis of rotationaxis of rotationDeriving the rotation matrix for such a rotation Deriving the rotation matrix for such a rotation directly is a good exercise in linear algebradirectly is a good exercise in linear algebraStandard approach: express general rotation as Standard approach: express general rotation as composition ofcomposition of canonical rotationscanonical rotations •Rotations about Rotations about X, Y, ZX, Y, ZComposing Canonical RotationsGoal: rotate about arbitrary vector Goal: rotate about arbitrary vector A A by by •Idea: we know how to rotate about Idea: we know how to rotate about XX,,YY,,ZZ–So, rotate about So, rotate about YY by by until until AA lies in the YZ plane lies in the YZ plane–Then rotate about Then rotate about XX by by until until AA coincides with + coincides with +ZZ–Then rotate about Then rotate about Z Z by by –Then reverse the rotation about Then reverse the rotation about X X (by -(by -))–Then reverse the rotation about Then reverse the rotation about Y Y (by -(by -))Goal: rotate about arbitrary vector Goal: rotate about arbitrary vector A A by by •Idea: we know how to rotate about Idea: we know how to rotate about XX,,YY,,ZZ–So, rotate about So, rotate about YY by by until until AA lies in the YZ plane lies in the YZ plane–Then rotate about Then rotate about XX by by until until AA coincides with + coincides with +ZZ–Then rotate about Then rotate about Z Z by by –Then reverse the rotation about Then reverse the rotation about X X (by -(by -))–Then reverse the rotation about Then reverse the rotation about Y Y (by -(by -))Composing Canonical RotationsFirst: rotating about First: rotating about YY by by until until AA lies in YZ lies in YZHow exactly do we calculate How exactly do we calculate ??•Project Project A A onto XZ plane (Throw away y-coordinate)onto XZ plane (Throw away y-coordinate)•Find angle Find angle that rotates A to that rotates A to x-axisx-axis:: = -(90° - = -(90° - ) = ) = - 90 ° - 90 °Second: rotating about x-axis by Second: rotating about x-axis by until until AA lies on lies on z-axisz-axisHow do we calculate How do we calculate ??First: rotating about First: rotating about YY by by until until AA lies in YZ lies in YZHow exactly do we calculate How exactly do we calculate ??•Project Project A A onto XZ plane (Throw away y-coordinate)onto XZ plane (Throw away y-coordinate)•Find angle Find angle that rotates A to that rotates A to x-axisx-axis:: = -(90° - = -(90° - ) = ) = - 90 ° - 90 °Second: rotating about x-axis by Second: rotating about x-axis by until until AA lies on lies on z-axisz-axisHow do we calculate How do we calculate ??Composing MatricesSo we have the following matrices:So we have the following matrices:•pp: The point to be rotated about : The point to be rotated about A A by by •RRyy : Rotate about : Rotate about YY by by •RRx x : Rotate about : Rotate about XX by by •RRzz : Rotate about : Rotate about ZZ by by •RRx x -1-1: Undo rotation about : Undo rotation about XX by by •RRyy-1-1 : Undo rotation about : Undo rotation about YY by by In what order should we multiply them?In what order should we multiply them?So we have the following matrices:So we have the following matrices:•pp: The point to be rotated about : The point to be rotated about A A by by •RRyy : Rotate about : Rotate about YY by by •RRx x : Rotate about : Rotate about XX by by •RRzz : Rotate about : Rotate about ZZ by by •RRx x -1-1: Undo rotation about : Undo rotation about XX by by •RRyy-1-1 : Undo rotation about : Undo
View Full Document