# 2D Geometric Transformations

## Presentation on theme: "2D Geometric Transformations"— Presentation transcript:

2D Geometric Transformations
Graphics Systems / Computer Graphics and Interfaces COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

2D Geometric Transformations
The geometric transformations in computer graphics are essential to position, change the orientation and scale objects in the scene created. The movement is also implemented by the processing parameters vary over time. Transformations: Translation Scaling Rotation COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Translation xT= X + Tx yT= Y + Ty
Vertices: (4,5) and (7,5) TxT = 3y= -4 The pair of translation is called for translation vector. Each vertex is assigned a displacement T: In the form of matrix product: COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Scaling xT= X * Sx yT* Y = Sy Regarding the origin. Sx = 2 Sy = 2
100 xT= X * Sx yT* Y = Sy Regarding the origin. 120 40 80 150 20 40 60 80 40 120 200 Sx = 2 Sy = 2 Sx = 2 Sy = -1.5 COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Scaling In matrix form: Scale Factor: > Increase the subject 1
<1 reduces the object sx= Sy Uniform scaling factor  does not distort the object COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Rotation x = R.cos (a) y = R.sen (a) Around the origin.
100 xRYR x = R.cos (a) R b x, y y = R.sen (a) Around the origin. the xRR.cos = (a + b) = R.cos (a). Cos (b) - R.sen (a). Sin (b) = x.cos (b) - y.sen (b) yRR.sen = (a + b) = R. Sin (b).cos (a) + R.sen (a). Cos (b) = x.sen (b) + y.cos (b) Obtains a new position on the previous and the relative angle of rotation. Rotation of -45 Vertices: (20.0) (60.0) (40,100) Vertices: (14:14, ), (42.43, ), (98.99, 42.43) COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Rotation + In matrix form:
Note: b positive movement in the opposite clockwise direction. + COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Composition of Transformations
Tc The application of a sequence of operations = 1 single transformation COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Composition of Transformations
Initial situation (20.0) (60.0) (40,100) After rotation (0, -20) (0, -60) (100, -40) a = - 90 ° After translation (-80, -20) (-80, -60) (20, -40) Tx = -80, Ty = 0 -80 0.0 100 20 60 Replacing the transformations: After translation (-60.0) (-20.0) ( ) Tx = -80, Ty = 0 After rotation (0.60) (0.20) (100.40) a = - 90 ° 100 20 60 Initial situation (20.0) (60.0) (40,100) 100 20 60 Conclusion: The application of the transformations is not commutative COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Homogeneous coordinates
The previous sequence, rotation, translation then applied to each vertex can be written as: 1 If the matrices representing the transformations were of the same size would be able to combine. 2 However, the above transformations can also be written as (homogeneously) We can then write: The matrix product is: Associative In general Noncommutative COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Homogeneous coordinates - summary
Rotation Matrix Matrix Translation Escalation Matrix In homogeneous coordinates of an object n dimensions is represented in space n +1 dimensions. (X, y)  (x.h, y.h h) 2D 3D We consider h = 1 COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Transformations - Examples
P '= T (dx1, Dy1) * P T (dx2, Dy2) T (dx1, Dy1) R'' = T (dx2, Dy2) * P ' P'' P T (?,?) R'' = T (dx2, Dy2) * T (dx1, Dy1) * P T (dx2, Dy2) * T (dx1, Dy1) = T (dx1+ Dx2, Dy1+ Dy2) Check that: O (sx2, Sy2) S * (sx1, Sy1) S = (sx1* Sx2, Sy1* Sy2) R (the2) * R (the1) = R (a2+ A1) COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Transformations on a arbitrary point (pivot)
Rotation The rotation moves objects around the origin. Rotation of -45 Solution: Traverse the object so that the point Anchorman coincides with the origin Rotating the object around the origin Making the translation of the object so that the point Anchorman return to starting position (inverse of first) COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Transformations on a arbitrary point (pivot)
Transformation matrix Scaling Traverse the object so that the point Anchorman coincides with the origin Climb the object Making the translation of the object so that the point Anchorman return to starting position (inverse of first) COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Exercise Determine the transformation matrix for: T (-x1,-y1)
If P1= (1,2) and P2= (3.3) determine the matrix of equivalent transformation. COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Other transformations
Reflection In relation to axis x corresponds to a 180 ° rotation in 3D space around the axis of reflection, which results in a scaling S (1, -1) y x x y In relation to axis y: COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Other transformations
Reflection relative to the line y = x x y x y Reflection relative to the line y =-x COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Inverse Transformations
If a transformation possibly composite is given by a matrix Mdimensions of 3x3, then the inverse transformation that puts the object in its initial position (ie no transformation) is given by M-1. Once M represents one or more transformations, the inverse matrix should be. M.M-1 = I For some transformations is easy to find the inverse matrix: Translation: Scaling: COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Exercise (Question of the May 23, 2002 test)
T(1,7)S(1,-3)T(0,-7). Nota: é necessário calcula-la [1 0 1] [ ] [0 0 1] Sim, porque o escalamento é feito sobre Y. Se fosse também sobre X a distância entre as letras aumentava. COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004

Similar presentations