Transformation.

Slides:



Advertisements
Similar presentations
COMPUTER GRAPHICS 2D TRANSFORMATIONS.
Advertisements

Computer Graphics Lecture 4 Geometry & Transformations.
Geometric Transformations
Arbitrary Rotations in 3D Lecture 18 Wed, Oct 8, 2003.
Three Dimensional Modeling Transformations
1 ME 302 DYNAMICS OF MACHINERY Dynamic Force Analysis IV Dr. Sadettin KAPUCU © 2007 Sadettin Kapucu.
1 Computer Graphics Chapter 6 2D Transformations.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Transformations II Week.
2D Geometric Transformations
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
2D/3D Geometric Transformations CS485/685 Computer Vision Dr. George Bebis.
Ch. 2: Rigid Body Motions and Homogeneous Transforms
Transformations I CS5600Computer Graphics by Rich Riesenfeld 27 February 2002 Lecture Set 5.
Transformations CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Computer Graphics with OpenGL 3e
2D Transformations x y x y x y. 2D Transformation Given a 2D object, transformation is to change the object’s Position (translation) Size (scaling) Orientation.
2D Transformations Unit - 3. Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it.
CS 450: Computer Graphics 2D TRANSFORMATIONS
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 2: Review of Basic Math
Mathematical Fundamentals
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
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.
Transformations Dr. Amy Zhang.
CS 480/680 Computer Graphics Transformations Dr. Frederick C Harris, Jr.
Lecture Notes: Computer Graphics.
Geometric Transformations Jehee Lee Seoul National University.
Dx = 2 dy = 3 Y X D Translation A translation is applied to an object by repositioning it along a straight-line path.
Part7: Geometric Transformations
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
Transformations Jehee Lee Seoul National University.
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Jinxiang Chai Composite Transformations and Forward Kinematics 0.
Geometric Objects and Transformation
Two-Dimensional Geometric Transformations ch5. 참조 Subjects : Basic Transformations Homogeneous Coordinates Composite Transformations Other Transformations.
Two-Dimensional Geometric Transformations A two dimensional transformation is any operation on a point in space (x, y) that maps that point's coordinates.
Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Geometric Transformations
GEOMETRIC TRANFORMATIONS Presented By -Lakshmi Sahithi.
Geometric Transformations Sang Il Park Sejong University Many slides come from Jehee Lee’s.
Composite 3D Transformations. Example of Composite 3D Transformations Try to transform the line segments P 1 P 2 and P 1 P 3 from their start position.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
Geometric Transformations UBI 516 Advanced Computer Graphics Aydın Öztürk
January 19, y X Z Translations Objects are usually defined relative to their own coordinate system. We can translate points in space to new positions.
3-D Geometric Transformations
3D Geometric Transformation
3D Geometric Transformation
3-D Transformational Geometry CS418 Computer Graphics John C. Hart.
Affine Geometry.
Graphics Lecture 2: Slide 1 Lecture 2 Transformations for animation.
II-1 Transformations Transformations are needed to: –Position objects defined relative to the origin –Build scenes based on hierarchies –Project objects.
Composite 3D Transformations. Example of Composite 3D Transformations Try to transform the line segments P 1 P 2 and P 1 P 3 from their start position.
Instructor: Mircea Nicolescu Lecture 9
III- 1 III 3D Transformation Homogeneous Coordinates The three dimensional point (x, y, z) is represented by the homogeneous coordinate (x, y, z, 1) In.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Computer Graphics I, Fall 2010 Transformations.
CS 325 Introduction to Computer Graphics 02 / 19 / 2010 Instructor: Michael Eckmann.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
2D Transformations What is transformations? The geometrical changes of an object from a current state to modified state. Why the transformations is needed?
CSCE 441 Computer Graphics: 2D Transformations
Modeling Transformation
Transformations. Modeling Transformations  Specify transformations for objects  Allows definitions of objects in own coordinate systems  Allows use.
CSE 167 [Win 17], Lecture 2: Review of Basic Math Ravi Ramamoorthi
3. Transformation
Computer Graphics CC416 Week 15 3D Graphics.
2D Transformations y y x x y x.
Chapter IV Spaces and Transforms
CSCE441: Computer Graphics 2D/3D Transformations
Presentation transcript:

Transformation

Matrix column and row transpose matrix composition identity matrix M-1 is an inverse matrix of M if MM-1=I.  1st row  2nd row  3rd row  1st column 2nd 3rd 3x2 2x3 3x3

Translation A transformation is a function that maps a point/vector into another point/vector. For now, we will discuss the basic 4 types of transformations: translation, scaling, rotation, and shearing. Translation ( x, y) dy (x, y) dx

Scaling Scaling is done about the origin. Scale x by sx along x-axis: x = sx·x Scale y by sy along y-axis: y = sy·y The above example is called a uniform scaling where sx = sy. If sx  sy, non-uniform scaling. If 0 < sx (or sy) < 1, objects are moved closer to the origin. If sx or sy > 1, objects are moved farther from the origin. e.g. x y (6,4) 3 6 x 2 4 (3,2) 2 e.g. x y (6,2) Scale by 1/2 along x Scale by 2 along y 3 6 (3,4) 4

Reflection Reflection or mirror matrix: a scaling matrix where (sx,sy) is either (1,-1) or (–1,1). (If both sx and sy are –1, it’s a 180o rotation.) y y x x y x x y

Rotation Rotation by an angle  about the origin. r The distance from P to the origin is r. Angles are measured CCW. x = r cos y = r sin x = r cos(+) = r cos cos - r sin sin = xcos - ysin y = r sin(+) = r cos sin + r sin cos = xsin + ycos For CW, you may use cos(-)=cos and sin(-)=-sin. P (x, y) r r r P(x, y)

Shearing Shearing along x y = y (unaffected) x = x + ay (in the example, a  0.5) Similarly, shearing along y y x

Homogeneous Coordinates Observe that rotation, scaling & shearing (which are collectively called linear transformations) are done by “matrix composition” while translation is by “vector addition.” Can we treat them uniformly? YES!! Use Homogeneous Coordinates. Practical motivations for Homogeneous Coordinates. We can treat {rotation, scaling, shearing, etc.} & {translation} uniformly. We can deal with projections (later!). A point (x, y) in Cartesian Coordinates is represented as (wx, wy, w) in Homogeneous Coordinates where w can be any non-zero value. e.g. (2 3)  (2 3 1) = (4 6 2) = (5 7.5 2.5) = …... but, typically w=1.

Transformations in Homogeneous Coordinates translation (x = x+dx, y = y+dy) scaling rotation shearing (along x) Note that all transformations are done by “matrix composition” thanks to homogeneous coordinates. Transformations which do not alter a body’s shape are called rigid-body transformations, and consist of rotations & translations.

Rotation about An Arbitrary Point How to rotate about an arbitrary point p(x, y), not about the origin? q=(a,b) q  q=(a,b) q q q  q q p =(x,y) p p=O p=O translate q by -p rotate by  back-translate 3x3 3x3 3x3 So far, we learned translation, scaling, rotation and shearing. You have to understand that the rotation is about the origin. But suppose that we want to rotate a point about another arbitrary point. Look. We want to rotate q about p, which is not the origin. If we apply the simple rotation matrix we learned, we got a weird result because it’s about the origin. If p were the origin, we wouldn’t have any problem. Again, if p were the origin, we wouldn’t have any problem. Then, why don’t we translate p to origin and apply the same translation to q? They still maintain the relative distance and orientation. Now we can apply the famous rotation matrix because p is now at origin. Is that it? No, we have to restore the initial translation. How? Simply do back-translation with the same distance and orientation. Do we have to move p? No, p just tells me that how much q should be moved. Everything to be transformed is q. It’s translated, rotated, and back-translated. translate translate & rotate translate, rotate & back-translate Thanks to Homogeneous Coordinates, three transformations can be combined into a single 3x3 matrix.

Inverse Transformation Note that the first and last translations are inverses of each other. Such an inverse transformation is represented as an inverse matrix, but can be obtained pretty easily if its geometry is considered. q q q q  q q p p=O p=O translate q by -p rotate by  back-translate inverse transformations x'=x+dx x'+?=x ?=- dx

Inverse Transformation (cont’d) scaling rotation shearing (along x) We have to restore y'(=y) into y and x'(=x+ay) into x, respectively. x'' = x' + ?y' = x' + ?y = x + ay + ?y = x. So, ?=-a x'=xxsx x'x?=x ?=1/sx y x

Associativity & Commutativity Matrix multiplication is associative. So is transformation composition. ABC = (AB)C = A(BC) In contrast, matrix multiplication is not commutative in general. Neither is transformation composition. e.g. combination of rotation (by 90°CCW) & translation along y rotation first translation first

3D Translation and Scaling First of all, Homogeneous Coordinate for 3D (x y z) → (wx wy wz w) e.g (x y z 1) Translation Scaling

3D Reflection Reflection or mirror matrix: a scaling matrix where one scaling factor is –1 and two others are 1 or all of the three scaling factors are –1. If two are –1, it’s a 180o rotation. reflection wrt yz-plane reflection wrt xz-plane reflection wrt xy-plane reflection wrt the origin

3D Rotation For 3D rotation, we need an axis of rotation. Also, by convention, positive angles are for CCW. Recall that, in 2D, x = xcos - ysin and y = xsin + ycos. We can consider (x,y) and (x,y) as points at xy-plane of 3D space. Add z-axis and make z = z. Then, it’s 3D rotation about the z-axis. y y (x, y) (x, y) (x, y, 0) (x, y, 0) x x z y (x, y, z) (x, y, z) x z Rz(θ)

3D Rotation (cont’d) Rotation about x-axis Note that the coordinate system follows the right hand rule. Let’s do cyclic permutation of the 3 axes, where the right hand rule holds. Note that rotation about x-axis is the same as rotation about the old z-axis except the permutation. For rotation about y-axis, do one more permutation! 3D shearing will be discussed when we deal with viewing. yz zx xy xyzx y' y z You have to understand that the coordinate system is right-handed. I mean, when the four fingers go from x to y, the thumb goes up along z direction. Let’s do a cyclic permutation on this right-handed coordinate system such that x becomes y, y becomes z, and then z becomes x. Look. The new coordinate systems is still right-handed. When the four fingers go from x to y, the thumb goes up along z direction. Now, we have two coordinate systems. The old black one, and the new red one. OK, let’s rotate a point around the x-axis in the red coordinate system. Then, does the x-coordinate value change? No, it does not. In the black coordinate system, z was not changed. Now, x takes the role. So, we can say x prime should be same as x. How about y and z? The red y and z are doing the same roles as the black x and y. So, we can get the rotated values y prime and z prime simply by applying cyclic permutation to the black x and y. y z' z x' x

Geometric Transformation of a Mesh Apply transformations to every vertex. Geometry is transformed. Topology(connectivities) is not changed. An example, Mesh A is displayed by drawing all of its edges (wireframe display). All vertices of A are rotated, scaled up and translated to make B, and then wireframe-displayed. Use the lists demonstrated in slide 6. Topology : eo-a This is the 3rd homework. A B

3D Rotation about An Arbitrary Axis z y x z by  x z Step1: Translate such that the rotation axis passes through the origin. Step2: Rotate such that the rotation axis coincides with a coordinate axis. Step3: Rotate by  y x z y x z y x z Step5: Inverse translation. (Inverse of Step1) Step4: Inverse rotation. (Inverse of Step2)

3D Rotation about An Arbitrary Axis (cont’d) Rotation axis is typically defined by 2 end points p1 and p2 (or a point p and a vector v) ∴ Move p1=(x1 y1 z1) to the origin. Consider the unit vector u along the rotation axis. y y p2(x2 y2 z2) p2 (x2 y2 z2) x x p1(x1 y1 z1) p1 (x1 y1 z1) z z p2(x2 y2 z2) p2 (x2 y2 z2) unit vector u p1(x1 y1 z1) p1 (x1 y1 z1)

3D Rotation about An Arbitrary Axis (cont’d) Step2 (from u to uz) requires a rather complicated process, which will be discussed soon. Just suppose the rotation is denoted by R. Step3 is simply Step4: an inverse of the matrix computed at Step2 Step5: an inverse of the matrix computed at Step1 R() is a single 4x4 matrix. y x z R u uz

Orthogonal Matrix Note that rotations we’ve devised are all about coordinate axes. Rotation for Step 2 is presented though orthogonal matrix. 2 rows vi & vj are orthonormal if i.e. ① each row is a unit vector, and ② any two different rows are orthogonal. Orthogonal matrix = a matrix with orthonormal rows. e.g. y x z R u uz ) ( 1 j i = ¹ orthogonal

Orthogonal Matrix (cont’d) A matrix Q is orthogonal  Q·QT = I (identity matrix) Observations An orthogonal matrix transforms its rows into coordinate axes. QT = Q-1, i.e. for orthogonal matrices, the transpose is the inverse. It’s great because inverse matrix computation is usually expensive. if Q is an orthogonal matrix, QT is also an orthogonal matrix. Q-1·Q = I = QT·Q  QT·(QT)T = I  QT is orthogonal. q 1 ... q 1 1 1 e.g. q 1 ... T 1 q T 2 q ... q 2 T n q = 2 T 1 q = ... 1 ... ... ... ... ... ... ... q ... 1 q n n nxn nxn nxn nxn nx1 nx1

3D Orthogonal Matrix The same thing applies to 3D. Suppose that we have 3 orthonormal vectors as follows. We can make orthogonal matrices using the 3 orthonormal vectors. If the 3 vectors constitute a coordinate system, i.e. the cross product of the 1st row and the 2nd row corresponds to the 3rd row following the right-hand rule, the orthogonal matrix is a rotation. uy v3 v2 ux uz v1 v1 v3 v1 v2 v1 v3 v3 v2 v2

3D Orthogonal Matrix (cont’d) uy 3D rotation in homogeneous coordinates. R transforms v1, v2 and v3 into ux, uy and uz, respectively. uz v3 v2 v1 v1 v2 ‘an’ orthogonal matrix v3 ux v1 ux v3 uz v2 uy

3D Rotation about An Arbitrary Axis (cont’d) Recall that, after Step1, our goal was to rotate u into uz. For this purpose, let’s make a rotation matrix whose 3rd row is u. u = v3 y x z 1 3 2 u=v v u =

3D Rotation about An Arbitrary Axis (cont’d) 1 3 2 u=v v u = v3 uy R = v2 x ux uz v1 z  is used to make be perpendicular to .  You can use any coordinate axis vector if it is not equal to u . Let’s simply put R into R()=T-1R-1Rz()RT. Importantly, RT is used for R-1.

Modeling Transformation

Modeling Transformation

Modeling Transformation p B A r p B A r

Modeling Transformation Translate by -r, bringing r to the origin. p B p B A r A A p B A p B

Modeling Transformation translate both A and B by –p, bringing p to the origin. A A p B p B p B Rotate A&B Translate A p B A

Modeling Transformation