1TransformationsMike [email protected]@ gOregon State Universitymjb – September 5, 2014Oregon State UniversityComputer GraphicsGeometry vs. Topology134Original Object12312341234Geometry = changedTopolog same (12341)mjb – September 5, 2014Oregon State UniversityComputer GraphicsWhere things are (e.g., coordinates)Geometry:How things are connectedTopology:2Topology = same (1-2-3-4-1)Geometry = sameTopology = changed (1-2-4-3-1)23D Coordinate SystemsYYXXZmjb – September 5, 2014Oregon State UniversityComputer GraphicsRight-HandedZLeft-HandedTransformationsYSuppose you have a point P and you want to move it over by 2 units in X – how would you hP’ dit?Xchange P’s coordinates?P P’(,)( 2.,)PPP P Pmjb – September 5, 2014Oregon State UniversityComputer Graphics(,)( 2.,)xyx yPPP P PThis is known as a coordinate transformation3General Form of 3D Linear TransformationsxAxByCzDyExFyGzHz IxJyKzL It’s called a “Linear Transformation” because all of the coordinates are raised to the 1stpower, that is, there are no x2, x3, etc. terms.mjb – September 5, 2014Oregon State UniversityComputer GraphicsTransform the geometry – leave the topology as isTranslation EquationsxxxTxyyyTzzzTyTmjb – September 5, 2014Oregon State UniversityComputer GraphicsxT4Scaling About the OriginxxS xxxSyyyS zzzS mjb – September 5, 2014Oregon State UniversityComputer Graphics2D Rotation About the Originicos sinxxysin cosyx ymjb – September 5, 2014Oregon State UniversityComputer Graphics5Linear Equations in Matrix FormxAx By Cz Dx consuming columnyExFyGzHzIxJyKzL xABCD xyEFGHy x’ producing rowy consuming columnz consuming columnconstant column’dimjb – September 5, 2014Oregon State UniversityComputer Graphics100011yEFGHyzIJKLz y’ producing rowz’ producing rowIdentity Matrix ( [ I ] )100001000010xxyyzz xxyyzzmjb – September 5, 2014Oregon State UniversityComputer Graphics[ I ] signifies that “Nothing has changed”0010100011zz 6Matrix Inverse[M]•[M]-1= [I][][][][M]•[M]-1= “Nothing has changed”mjb – September 5, 2014Oregon State UniversityComputer Graphics“Whatever [M] does, [M]-1undoes”Translation Matrix100010001xyxTxyTyT mjb – September 5, 2014Oregon State UniversityComputer Graphics001100011zzTz Quick! What is the inverse of this matrix?7Scaling Matrix00000000 0xyxSxySyzSz mjb – September 5, 2014Oregon State UniversityComputer Graphics00 0100011zzSz Quick! What is the inverse of this matrix?3D Rotation Matrix About ZRight-handed coordinatesYRight-handed positive rotation rule+90º rotation gives: y’ = xXYmjb – September 5, 2014Oregon State UniversityComputer Graphicscos sin 0 0sin cos 0 00010100011xxyyzz Z83D Rotation Matrix About YYX+90º rotation gives: x’ = zmjb – September 5, 2014Oregon State UniversityComputer GraphicsZcos 0 sin 00100sin 0 cos 0100011xxyyzz 3D Rotation Matrix About XY+90º rotation gives: z’ = yXmjb – September 5, 2014Oregon State UniversityComputer GraphicsZ10 0 00cos sin 00sin cos 0100 011xxyyzz 9How it Really Works :-)http://xkcd.commjb – September 5, 2014Oregon State UniversityComputer GraphicsCompound TransformationsBBYQ: Our rotation matrices only work around the origin? What if we want to rotate about an arbitrary point (A,B)?AUth tiAAWrite itXxx A: Use more than one matrix.123mjb – September 5, 2014Oregon State UniversityComputer GraphicsSay it,,11AB AByyTRTzz 10Matrix Multiplication is not CommutativeYYXRotate, then translateYXmjb – September 5, 2014Oregon State UniversityComputer GraphicsTranslate, then rotateXMatrix Multiplication is AssociativeAB ABxxyyTRT ,,11AB ABzz xxyy mjb – September 5, 2014Oregon State UniversityComputer Graphics,,11AB AByyTRTzz One matrix –the Current Transformation Matrix, or CTM}11Can Multiply All Geometry by One Matrix !BBYAAX[]xxyyzzM mjb – September 5, 2014Oregon State UniversityComputer GraphicsGraphics hardware can do this very quickly!11 OpenGL Will Do the Transformation Compounding for You !glTranslatef( A, B, C );glRotatef( (GLfloat)Yrot, 0., 1., 0. );glRotatef( (GLfloat)Xrot, 1., 0., 0. );glScalef( (GLfloat)Scale, (GLfloat)Scale, (GLfloat)Scale );oat)Scale );g((),(),());glCallList( BoxList );C );at)Yrot, 0., 1.,
View Full Document