180 likes | 320 Views
ME 521 Computer Aided Design. 8. 2D Coordinate Operations. Dr . Ahmet Zafer Şenalp e-mail: azsenalp@gyte.edu.tr Makine Mühendisliği Bölümü Gebze Yüksek Teknoloji Enstitüsü. Introduction. 8. 2D Coordinate Operations.
E N D
ME 521 ComputerAidedDesign 8. 2D CoordinateOperations Dr. Ahmet Zafer Şenalpe-mail: azsenalp@gyte.edu.tr Makine Mühendisliği Bölümü Gebze Yüksek Teknoloji Enstitüsü
Introduction 8. 2D CoordinateOperations Many of the engineering problems are solved by defining the model in 2D. Within these problems; • Standard kinematics problems • Some mechanism movements • Shear force bending moment graphics of structural members can be listed. For the representation of these problems basic graphics elements such as line, circle are needed. Additionally transformations should be applied to the basic graphics elements to obtain the desired graphical view. Fundamental operations in graphics work can be summarized as follows: • Translation • Rotation • Scaling GYTE-Makine Mühendisliği Bölümü
2D Transformations Translation 8. 2D CoordinateOperations • Translation: A translation is moving every point a constant distance in a specified direction. It is one of the rigid motions. Mathematically; x' = x + Tx y' = y + Ty Here; x y : initial coordinates x' y' : final coordinates. GYTE-Makine Mühendisliği Bölümü
2D Transformations Translation Example: 8. 2D CoordinateOperations A triangle is given below with [(20,0) (60,0) (40,100)] vertex coornitaes This triangle is translated 100 units to right 10 units to up; Tx = 100, Ty = 10 and x' = x + Tx y' = y + Ty The new vertex coordinates of the triangle is: [(120,10) (160,10) (140,110)] Ötelemeörneği GYTE-Makine Mühendisliği Bölümü
2D Transformations Rotation 8. 2D CoordinateOperations • Rotation: A point (x,y) is rotated in counter clockwise direction around the center of the coordinate axis. The new coordinates can be calculated as follows: ( PS: Obeying to the right hand rule counter clockwise direction is taken to be positive.) x = r cosa y = r sina x’ = r cos (+ ) = r ( coscos - sin sin ) = r coscos - r sin sin = x cos - y sin y’ = r sin (+ ) = r ( sin cos + cos sin ) = r sin cos + r sin cos = x sin + y cos As a result: x’ = x cos - y sin y’ = x sin + y cos İs obtained. P(x,y) noktasının saat yönünün tersi yönünde q açısıyla döndürülmesi GYTE-Makine Mühendisliği Bölümü
2D Transformations Rotation Example: 8. 2D CoordinateOperations The triangle given in translation example with initial coordinates [(20,0) (60,0) (40,100)] is rotated around the coordinat system’s center in clock wise direction with an angle of 45 degrees. The new coordinates of the triangle are: PS: These equations are used for the rotation about center point O only. GYTE-MakineMühendisliğiBölümü
2D Transformations Scaling 8. 2D CoordinateOperations • Scaling: To change the scale of an object x' = x Sx y' = y Sy equations are used. GYTE-Makine Mühendisliği Bölümü
2D Transformations Scaling Example: 8. 2D CoordinateOperations Given the triangle with vertex coordinates [(20,0) (60,0) (40,100)] Calculate the new coordinates when the size of the triangle is scaled by 2 Sx = Sy =2 New coordinates are calculated to be: (40,0) (120,0) (80,200) GYTE-Makine Mühendisliği Bölümü
2D Transformations Scaling Example: 8. 2D CoordinateOperations PS: When Sx and Sy are used with different magnitudes the image will be distorted. By using scaling mirror images shown below can be obtained. GYTE-Makine Mühendisliği Bölümü
Concatenation 8. 2D CoordinateOperations Sequential transformations can be concatenated . As an example a rotation about an arbitrary point can be written as: translation + rotation + translation The mentioned sequence is important. Example: A body; • Rotated about coordinate system’s center 90 degrees counter clock wise • Translated -80 units in x direction (Tx = - 80, Ty = 0); İs obtained. If operation sequence is changed different result will be obtained. Concatenation is prefered as less arithmetic operation is necessary. or GYTE-Makine Mühendisliği Bölümü
MatrixRepresentations 8. 2D CoordinateOperations 2D transfomations can be conducted by using a 3 x 3 matrix (x , y) coordinates are transformed to ( x' , y‘): addition of units to the [ x , y ] vector enables it to be transformed by the 3 x 3 matrix GYTE-Makine Mühendisliği Bölümü
MatrixRepresentations 8. 2D CoordinateOperations Translation: Rotation: Scaling: GYTE-Makine Mühendisliği Bölümü
Concatenation of MatrixTransformations 8. 2D CoordinateOperations Consider scaling Sx = Sy = 2 , then translate it with Tx = 10, Ty = 0 Scaling: Translate: GYTE-Makine Mühendisliği Bölümü
Concatenation of MatrixTransformations 8. 2D CoordinateOperations The result [ x' y' 1] is merely an intermediate one and we can eliminate it by subtituting the first equation into the second: The two 3 x 3 matrices are independent of the ( x , y ) points being transformed, and are derived only from the parameters specified in the transformation sequence ( Sx, Sy, Tx, Ty). Therefore the product of the two matrices can be used. Thus the product of two matrix transformations represents the concatenation of those transforms. Irrespective of the number of transformation, we can always concatenate so that one 3 x 3 matrix represents the entire sequence. GYTE-Makine Mühendisliği Bölümü
RotationAbout an ArbitraryPoint 8. 2D CoordinateOperations Suppose we wish to derive a transformation whichwill rotate a point through a clockwise angle about a point (Px , Py). • The rotation transformation can be applied to rotate points about the origin. Therefore we must first translate points so that (Px , Py) becomes the origin: 2. Thenrotation is applied. GYTE-Makine Mühendisliği Bölümü
RotationAbout an ArbitraryPoint 8. 2D CoordinateOperations • And finally we translate the point so that the origin is returned to (Px , Py): These operations may be concatenated: If Px, Py and are known three matrices can be multiplied to yield one transformation matrix GYTE-Makine Mühendisliği Bölümü
Efficiency 8. 2D CoordinateOperations When generating a picture for display, we may need to apply a transformation to a large number of points. This application must be as efficient as possible. the computation seems at a first glance to require 9 multiplications and 6 additions. However, in the formulation given here, the third column of the 3 x 3 matrix will always be: even if the matrix is result of many concatenations, the computations for x' and y' reduces to: x' = ax + by +c y' = dx + ey +f which reduces to 4 multiplications and 4 additions. GYTE-Makine Mühendisliği Bölümü
Efficiency 8. 2D CoordinateOperations A matrix rotation for this abbreviated computation is: The transformation matrix is now a 3 x 2 matrix. However we cannot concatenate two 3 x 2 matrices by multiplying them together: before we multiply them we must first return them to 3 x 3 form by attaching a third column. GYTE-Makine Mühendisliği Bölümü