ME 521 Computer Aided Design 10 2 D

  • Slides: 18
Download presentation
ME 521 Computer Aided Design 10. 2 D Coordinate Operations Assoc. Prof. Dr. Ahmet

ME 521 Computer Aided Design 10. 2 D Coordinate Operations Assoc. Prof. Dr. Ahmet Zafer Şenalp e-mail: azsenalp@gmail. com e-mail: Mechanical Engineering Department Gebze Technical University

Introduction 10. 2 D Coordinate Operations Many of the engineering problems are solved by

Introduction 10. 2 D Coordinate Operations Many of the engineering problems are solved by defining the model in 2 D. 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 Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 2

2 D Transformations 10. 2 D Coordinate Operations Translation • Translation: A translation is

2 D Transformations 10. 2 D Coordinate Operations Translation • 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. Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 3

2 D Transformations 10. 2 D Coordinate Operations Translation Example: A triangle is given

2 D Transformations 10. 2 D Coordinate Operations Translation Example: 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 Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 4

2 D Transformations Rotation 10. 2 D Coordinate Operations • Rotation: A point (x,

2 D Transformations Rotation 10. 2 D Coordinate Operations • 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 cos y = r sin x’ = r cos ( + ) = r ( cos - sin ) = r cos - r 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. Dr. Ahmet Zafer Şenalp ME 521 P(x, y) noktasının saat yönünün tersi yönünde açısıyla döndürülmesi Mechanical Engineering Department, GTU 5

2 D Transformations Rotation 10. 2 D Coordinate Operations Example: The triangle given in

2 D Transformations Rotation 10. 2 D Coordinate Operations Example: 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. Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 6

10. 2 D Coordinate Operations 2 D Transformations Scaling • Scaling: To change the

10. 2 D Coordinate Operations 2 D Transformations Scaling • Scaling: To change the scale of an object x' = x Sx y' = y Sy equations are used. Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 7

2 D Transformations Scaling 10. 2 D Coordinate Operations Example: Given the triangle with

2 D Transformations Scaling 10. 2 D Coordinate Operations Example: 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) Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 8

2 D Transformations Scaling Example: 10. 2 D Coordinate Operations PS: When Sx and

2 D Transformations Scaling Example: 10. 2 D Coordinate Operations 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. Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 9

Concatenation 10. 2 D Coordinate Operations Sequential transformations can be concatenated. As an example

Concatenation 10. 2 D Coordinate Operations 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; 1. Rotated about coordinate system’s center 90 degrees counter clock wise 2. Translated -80 units in x direction (Tx = - 80, Ty = 0); Rotation x' = y y' = -x Translation x'' = x' - 80 y'' = y' Concatenation or x'' = y - 80 y'' = -x İs obtained. If operation sequence is changed different result will be obtained. Concatenation is prefered as less arithmetic operation is necessary. Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 10

Matrix Representations 10. 2 D Coordinate Operations 2 D transfomations can be conducted by

Matrix Representations 10. 2 D Coordinate Operations 2 D 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 Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 11

Matrix Representations 10. 2 D Coordinate Operations Translation: Rotation: Scaling: Dr. Ahmet Zafer Şenalp

Matrix Representations 10. 2 D Coordinate Operations Translation: Rotation: Scaling: Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 12

Concatenation of Matrix Transformations 10. 2 D Coordinate Operations Consider scaling Sx = Sy

Concatenation of Matrix Transformations 10. 2 D Coordinate Operations Consider scaling Sx = Sy = 2 , then translate it with Tx = 10, Ty = 0 Scaling: Translate: Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 13

Concatenation of Matrix Transformations 10. 2 D Coordinate Operations The result [ x' y'

Concatenation of Matrix Transformations 10. 2 D Coordinate Operations 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. Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 14

Rotation About an Arbitrary Point 10. 2 D Coordinate Operations Suppose we wish to

Rotation About an Arbitrary Point 10. 2 D Coordinate Operations Suppose we wish to derive a transformation which will rotate a point through a clockwise angle about a point (Px , Py). 1. 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. Then rotation is applied. Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 15

Rotation About an Arbitrary Point 10. 2 D Coordinate Operations 3. And finally we

Rotation About an Arbitrary Point 10. 2 D Coordinate Operations 3. 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 Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 16

Efficiency 10. 2 D Coordinate Operations When generating a picture for display, we may

Efficiency 10. 2 D Coordinate Operations 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. Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 17

Efficiency 10. 2 D Coordinate Operations A matrix rotation for this abbreviated computation is:

Efficiency 10. 2 D Coordinate Operations 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. Dr. Ahmet Zafer Şenalp ME 521 Mechanical Engineering Department, GTU 18