Computer Graphics Geometric Transformations
Contents coordinate sstems scalar values, points, vectors, matrices right-handed and left-handed coordinate sstems mathematical foundations transformations mathematical descriptions of geometric changes, 2D and 3D matrices: efficient representation matrices for common transformations z Computer Graphics Fall 26/27
The Basics Introduction and Motivation Mathematical Tools Coordinate Sstems Computer Graphics Fall 26/27
Introduction and Motivation 3D models represented as points, edges, polgons in 3D coordinate sstems object coordinate sstems world coordinate sstem camera coordinate sstem screen coordinate sstem transformations necessar foundation: geometr and linear algebra Computer Graphics Fall 26/27
Scalars, Points, Vectors, Matrices scalar values: real (rational) numbers: 7.39 points: position in nd space: (2.53, -.78) T vectors: directions in nd space have no position in space is linear combination of basis vectors of the vector space, e.g., (a, b, c) T = a(,, ) T + b(,, ) T + c(,, ) T matrices (n m): transformations between vector spaces Computer Graphics Fall 26/27
Coordinate Sstem and Coordinates coordinate sstem: set (o, e, e 2,..., e n ) consisting of point oa n and basis (e, e 2,...,e n ) of vector space A n position vector v = (op) for each pa n coordinates: scalar components of v with respect to (e, e 2,...,e n ) v = e + 2 e 2 +...+ n e n o: point of origin o z c(,,) b(,,) a(,,) (a,b,c) Computer Graphics Fall 26/27
Coordinate Sstems in CG: 2D & 3D two-dimensional three-dimensional 2 mirrored sstems cannot be matched b rotation we use right-handed z left-handed coordinate sstem z right-handed coordinate sstem Computer Graphics Fall 26/27
Transformations in 2D: Translation, Scaling, Rotation Computer Graphics Fall 26/27
Transformations in 2D goal: represent changes and movements of objects in the vector space common transformations: translation rotation scaling mirroring shearing combinations of these Computer Graphics Fall 26/27
2D Translation move point (, ) T on a straight line to (, ) T represent translation b a translation vector that is added d d vector: movement from one point to another d (,) d (, ) Computer Graphics Fall 26/27
2D Uniform Scaling center of scaling is o scaling uniforml in all directions stretching of (, ) T s position vector b scalar factor to get (, ) T mathematicall: multiplication with (,) (, ) Computer Graphics Fall 26/27
2D Non-Uniform Scaling center of scaling is o scaling in -direction b and in -direction b b (scaling vector (, b) T ) mathematicall: multiplication with and b according to ais ß application: mirroring (,) (, ) Computer Graphics Fall 26/27
2D Rotation center of rotation is o point (, ) T is rotated b an angle around o to obtain (, ) T positive angles mean counter-clockwise rotation (, ) (,) Computer Graphics Fall 26/27
2D Rotation Derivation of Formula distances (,) T o & (, ) T o are both r = r cosf and = r sinf = r cos(+f) and = r sin(+f) addition theorems (, ) = r cos cosf r sin sinf = cos sin r = r sin cosf + (,) r cos sinf r f r cosf = sin + cos r cos( + f) Computer Graphics Fall 26/27
2D Rotation = cos sin = sin + cos can be epressed as matri multiplication cos sin sin cos rotations around negative angles result in clockwise motion use smmetr of triginometric functions: cos(-)=cos() and sin(-)=-sin() Computer Graphics Fall 26/27
Transformations in 2D: Results translation: scaling: rotation: problems: addition of translation vector multiplication of factor(s) matri multiplication non-uniform treatment of transformations no wa to combine N transformation into one idea: all transformations as matri multiplications! onl scaling and translation to do Computer Graphics Fall 26/27
Transformations in 2D: Matri Formulation Homogeneous Coordinates Computer Graphics Fall 26/27
Computer Graphics Fall 26/27 Scaling using 2D Matri general 2D matri multiplication format scaling formula scaling as matri multiplication d c b a ) with (possibl b ß b
Computer Graphics Fall 26/27 Translation using 2D Matri general matri multiplication format tanslation formula translation as matri multiplication d c b a???? d d not possible in 2 2 matri!
Transformations in 2D: What now? translation: scaling: rotation: addition of translation vector matri multiplication matri multiplication onl scaling and rotation possible as matri multiplication possible solutions don t use translations? use both matrices and vector adding? mathematical magic: homogeneous coordinates! Computer Graphics Fall 26/27
Homogeneous Coordinates in 2D add an additional dimension to our vector space A n : n n+ (, ) T represented as (w, w, w) T, w normalized using w = (,, ) T homogeneous coordinates are not to be confused with regular 3D coordinates! Computer Graphics Fall 26/27
Homogeneous Coordinates in 2D each point in A n is equivalent to a line in homogeneous space A n+ that originates in the origin o but without including o w 3 2 Computer Graphics Fall 26/27
Computer Graphics Fall 26/27 Homogeneous Coordinates in 2D advantages of homogeneous coordinates uniform treatment of transformations all transformations can be represented combined transformations as one matri procedure: matri-vector multiplication goal: derive transformation matrices w i h g f e d c b a w
Computer Graphics Fall 26/27 Translation in Homogeneous Coords general matri multiplication format translation formula translation as matri multiplication d d w i h g f e d c b a w d d d d
Computer Graphics Fall 26/27 Scaling in Homogeneous Coords scaling as matri multiplication scaling as homogeneous matri multiplication b b b
Computer Graphics Fall 26/27 Rotation in Homogeneous Coords rotation as matri multiplication rotation as homogeneous matri multiplication cos sin sin cos cos sin sin cos cos sin sin cos
Computer Graphics Fall 26/27 Homogeneous Coordinates in 2D general transformation matri what about normalizing w when done? in all basic transformations we get w = no normalization necessar f e d c b a scaling rotation translation f e d c b a
Transformations in 2D: Inverse Transformations Concatenating Transformations Computer Graphics Fall 26/27
Inverse Transformations how to reverse basic transformations? translation: scaling: rotation: using negative vector T - (d, d) = T(-d, -d) using inverted factor / S - () = S( / ) using negative angle R - () = R(-) also: rotation matrices are orthonormal R - = R T Computer Graphics Fall 26/27
Computer Graphics Fall 26/27 Concatenating Transformations two translations translations are additive result is a translation b the sum of both vectors 2 2 d d d d = d + d 2 d + d 2
Computer Graphics Fall 26/27 Concatenating Transformations two scalings scaling is multiplicative result is a scaling b the product of both factors 2 2 b b 2 2 b b
Computer Graphics Fall 26/27 Concatenating Transformations two rotations rotation is additive (addition theorems) result is a rotation around the sum of both angles ) cos( ) sin( ) sin( ) cos( 2 2 2 2 cos sin sin cos cos sin sin cos 2 2 2 2
Concatenating Transformations in general, concatenating transformations b multipling their homogenous matrices given n transformations T, T 2,..., T n all are to be concatenated so that T is processed first, T 2 second,..., and T n last P = T n... T 2 T P onl for column vectors (points)! row vectors (points): P = P T T 2... T n we use column vectors (points) Computer Graphics Fall 26/27
Using Concatenated Transformations eample: rotation around arbitrar point P three steps: translation into origin rotation inverse translation to bring back to P P = T + R T - P P P Computer Graphics Fall 26/27
Using Concatenated Transformations all matrices for one concatenated transformation can be multiplied into one (as preprocessing) but: matri multiplication is not commutative! the order matters! (as with normal transformations, too) T n...t 2 T P T T 2...T n P T 2 T n...t P in most cases (depending on T i ) some transformations are commutative (just translating; just scaling; just rotating) Computer Graphics Fall 26/27
Concatenating Transformations 2 2 Rotation and Translation P = T R P P = R T P 2 2 Scaling and Translation P = T S P P = S T P Computer Graphics Fall 26/27
Concatenating Transformations 3 3 2 2 Rotation, Scaling, Translation P = T S R P P = R T S P 4 4 3 2 3 2 Rot., Scal., neg. Rot., Trans. P = T R - S R + P? P = R + T R - S P Computer Graphics Fall 26/27
Concatenating Transformations efficienc eample model with,, vertices operations: scaling, rotation, translation individual matri multiplications: 3 (9M + 6A),, = 27,,M 8,,A one concatenated matri : (9M + 6A),, = 9,,M 6,,A Computer Graphics Fall 26/27
Computer Graphics Fall 26/27 Other Transformations in 2D mirroring non-uniform scaling using - & as factors M Y M X
Computer Graphics Fall 26/27 Other Transformations in 2D shearing in -direction in -direction a T b T a b (,) (, ) a=, =4 a=, =
Computer Graphics 3D Geometric Transformations Computer Graphics Fall 26/27
Contents transformations continued transitioning from 2D to 3D z Computer Graphics Fall 26/27
Geometric Transformations in 3D same approach as in 2D also use homogeneous coordinates (for the same reasons) vectors/points from 3D to 4D z z transformation matrices are now 4 4 (instead of 3 3) Computer Graphics Fall 26/27
Transformation Matrices in 3D translation translation vector (d, d, dz) T scaling for uniform scaling s = s = s z otherwise individual factors ma differ mirroring using factors of - and depending on the mirror plane T s S s s d d dz z Computer Graphics Fall 26/27
Transformation Matrices in 3D rotation rotation around 3 aes possible now each has individual rotation matri rotation around positive angles in right-handed coordinate sstem rotation ais stas unit vector in matri R R R z cos sin cos sin cos sin sin cos sin cos sin cos Computer Graphics Fall 26/27
Transformation Matrices in 3D rotation wh are signs different from 2D case for R? R cos sin sin cos z right-handed coordinate sstem z contrast to 2D case: mirroring on -ais (, -) Computer Graphics Fall 26/27
Concatenating Transformations in 3D matri multiplication just as in 2D general transformation matri in 3D T a e i m b f j n c g k o d h l p scaling rotation translation Computer Graphics Fall 26/27
Transformations: Summar geometric transformations: linear mapping from n to n we are interested in 2 2 and 3 3 transformations most relevant for CG: translation rotation scaling mirroring shearing Computer Graphics Fall 26/27
Transformations: Summar unified representation of geometric transformations as matrices in homogeneous coordinates concatenation of transformation b multipling the respective matrices order matters: for column vectors the first transformation comes last in the sequence concatenated transformations can be pre-computed (saving run-time) Computer Graphics Fall 26/27