210 likes | 740 Views
2D Geometric Transformations. Graphics Systems / Computer Graphics and Interfaces. 2D Geometric Transformations.
E N D
2D Geometric Transformations Graphics Systems / Computer Graphics and Interfaces 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 COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004
Translation Vertices: (4,5) and (7,5) TxT = 3y= -4 xT= X + Tx yT= Y + Ty The pair of translation is called for translation vector. Each vertex is assigned a displacement T: In the form of matrix product: COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004
40 80 120 200 150 40 120 80 Scaling xT= X * Sx 100 yT* Y = Sy Regarding the origin. 40 20 60 Sx = 2 Sy = 2 Sx = 2 Sy = -1.5 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 COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004
Rotation x = R.cos (a) 100 xRYR R b y = R.sen (a) Around the origin. x, y 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: (14:14, -14.14), (42.43, -42.43), (98.99, 42.43) Vertices: (20.0) (60.0) (40,100) COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004
Rotation In matrix form: Note:b positive movement in the opposite clockwise direction. + COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004
Composition of Transformations T2 The application of a sequence of operations = 1 single transformation T1 T3 Tc COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004
100 20 60 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 Replacing the transformations: -80 0.0 100 20 60 After translation (-60.0) (-20.0) (-40.100) Tx = -80, Ty = 0 After rotation (0.60) (0.20) (100.40) a = - 90 ° Initial situation (20.0) (60.0) (40,100) 100 20 60 Conclusion: The application of the transformations is not commutative 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 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 COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004
Transformations - Examples P ' T (dx2, Dy2) * T (dx1, Dy1) = T (dx1+ Dx2, Dy1+ Dy2) 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 Check that: O (sx2, Sy2) S * (sx1, Sy1) S = (sx1* Sx2, Sy1* Sy2) R (the2) * R (the1) = R (a2+ A1) 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) 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) COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004
Exercise Determine the transformation matrix for: R (90) T (x2, y2) T (-x1,-y1) S (0.5,0.5) If P1= (1,2) and P2= (3.3) determine the matrix of equivalent transformation. COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004
y x 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 In relation to axis y: COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004
y x y x Other transformations Reflection relative to the line y = x Reflection relative to the line y =-x 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: COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004
Exercise (Question of the May 23, 2002 test) COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 2004