DOC PREVIEW
Berkeley COMPSCI 184 - Transformations

This preview shows page 1-2-3-21-22-23-42-43-44 out of 44 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 44 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 44 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 44 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 44 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 44 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 44 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 44 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 44 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 44 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 44 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS-184: Computer GraphicsLecture #4: 2D Transformations Prof. James O’BrienUniversity of California, BerkeleyV2007-F-04-1.02Today2D Transformations“Primitive” OperationsScale, Rotate, Shear, Flip, TranslateHomogenous CoordinatesSVDStart thinking about rotations...3IntroductionTransformation: An operation that changes one configuration into anotherFor images, shapes, etc.A geometric transformation maps positions that define the object to other positionsLinear transformation means the transformation is defined by a linear function... which is what matrices are good for.4Some ExamplesImages from Conan The Destroyer, 1984OriginalUniform ScaleRotationNonuniform ScaleShear5Mapping Functionc(x)=[195, 120, 58]f (x)=x in old imagec!x = c( f (x))6Linear -vs- NonlinearLinear (shear)Nonlinear (swirl)7Geometric -vs- Color SpaceLinear Geometric(flip)Color Space Transform(edge finding)8InstancingRHWM.C. Escher, from Ghostscript 8.0 Distribution9InstancingRHWReuse geometric descriptionsSaves memory10Linear is LinearPolygons defined by pointsEdges defined by interpolation between two pointsInterior defined by interpolation between all pointsLinear interpolation11Linear is LinearComposing two linear function is still linearTransform polygon by transforming verticesScale12Linear is LinearComposing two linear function is still linearTransform polygon by transforming verticesf (x)=a + bxg( f )=c + dfg(x)=c + df(x)=c + ad + bdxg(x)=a!+ b!x13Points in SpaceRepresent point in space by vector in Relative to some origin!Relative to some coordinate axes!Later we’ll add something extra...RnOrigin, 024p =[4, 2]T14Basic TransformationsBasic transforms are: rotate, scale, and translateShear is a composite transformation!RotateTranslateScaleShear -- not really “basic”Uniform/isotropicNon-uniform/anisotropic15Linear Functions in 2Dx!= f (x, y)=c1+ c2x + c3yy!= f (x, y)=d1+ d2x + d3y!x!y!"=!txty"+!MxxMxyMyxMyy"·!xy"x!= t + M · x16RotationsRotatepp−=)Cos()()()Cos('θθθθSinSinx.707 -.707.707 .707yx45 degree rotation17RotationsRotations are positive counter-clockwiseConsistent w/ right-hand ruleDon’t be different...Note: rotate by zero degrees give identityrotations are modulo 360 (or )2π18RotationsPreserve lengths and distance to originRotation matrices are orthonormal In 2D rotations commute... But in 3D they won’t!Det(R)=1 != −119Scales0.5 0 0 1.5xyxyx0.5 0 0 0.5yxyScaleUniform/isotropicNon-uniform/anisotropicpp=yxss00'20ScalesDiagonal matricesDiagonal parts are scale in X and scale in Y directionsNegative values flipTwo negatives make a positive (180 deg. rotation)Really, axis-aligned scalesNot axis-aligned...21ShearsShearpp=11'xyyxHHx 1 1 0 1yxy22ShearsShears are not really primitive transformsRelated to non-axis-aligned scalesMore shortly.....23TranslationThis is the not-so-useful way:Translate+=yxttpp'Note that its not like the others.24Arbitrary MatricesFor everything but translations we have:Soon, translations will be assimilated as wellWhat does an arbitrary matrix mean?x!= A · x25Singular Value DecompositionFor any matrix, , we can write SVD: where Q and R are orthonormal and S is diagonalCan also write Polar Decomposition where Q is still orthonormalATQSRA =TQRSRA =not the same Q26Decomposing MatricesWe can force Q and R to have Det=1 so they are rotationsAny matrix is now:Rotation:Rotation:Scale:RotationSee, shear is just a mix of rotations and scales27CompositionMatrix multiplication composites matricesSeveral translations composted to oneTranslations still left out...BApp ='“Apply A to p and then apply B to that result.”CppBAApBp === )()('uCpBtBAptApBp +=+=+= )('28CompositionshearxyxyyxxshearshearTransformations built up from othersSVD builds from scale and rotationsAlso build other waysi.e. 45 deg rotation built from shears29Move to one higher dimensional spaceAppend a 1 at the end of the vectorsHomogeneous Coordiantes=yxppp=1~yxppp30Homogeneous Translation=11001001'~yxyxppttppAp~~'~=The tildes are for clarity to distinguish homogenized from non-homogenized vectors.31Homogeneous Others=10000~AANow everything looks the same...Hence the term “homogenized!”32Compositing MatricesRotations and scales always about the originHow to rotate/scale about another point?-vs-33Rotate About Arb. PointStep 1: Translate point to originTranslate (-C)34Rotate About Arb. PointStep 1: Translate point to originStep 2: Rotate as desiredTranslate (-C) Rotate (θ)35Don’t negate the 1...Step 1: Translate point to originStep 2: Rotate as desiredStep 3: Put back where it wasRotate About Arb. PointTranslate (-C) Rotate (θ) Translate (C) pApRTTp~~)('~=−=36Scale About Arb. AxisDiagonal matrices scale about coordinate axes only:Not axis-aligned37Scale About Arb. AxisStep 1: Translate axis to origin38Scale About Arb. AxisStep 1: Translate axis to originStep 2: Rotate axis to align with one of the coordinate axes39Scale About Arb. AxisStep 1: Translate axis to originStep 2: Rotate axis to align with one of the coordinate axesStep 3: Scale as desired40Scale About Arb. AxisStep 1: Translate axis to originStep 2: Rotate axis to align with one of the coordinate axesStep 3: Scale as desiredSteps 4&5: Undo 2 and 1 (reverse order)41Order Matters!The order that matrices appear in mattersSome special cases work, but they are specialBut matrices are associativeThink about efficiency when you have many points to transform...A · B != BA(A · B) · C = A · (B · C)42Matrix InversesIn general: undoes effect of Special cases:Translation: negate and Rotation: transposeScale: invert diagonal (axis-aligned scales)Others:Invert matrixInvert SVD matrices A−1Atxty43Point Vectors / Direction VectorsPoints in space have a 1 for the “w” coordinateWhat should we have for ? Directions not the same as positionsDifference of positions is a directionPosition + direction is a positionDirection + direction is a directionPosition + position is nonsensea − bw = 044Somethings Require CareFor example normals do not transform normallyM(a × b) "=(Ma) × (Mb)M(Re) !=


View Full Document

Berkeley COMPSCI 184 - Transformations

Documents in this Course
Load more
Download Transformations
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Transformations and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Transformations 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?