Upload
johnathan-hodges
View
221
Download
4
Embed Size (px)
Citation preview
8. 2D Coordinate Operations
Assoc.Prof.Dr. Ahmet Zafer Şenalpe-mail: [email protected]
Mechanical Engineering DepartmentGebze Technical University
ME 521Computer Aided Design
Introduction
Many of the engineering problems are solved by defining the model in 2D. Within these problems;
Standard kinematics problemsSome mechanism movementsShear force bending moment graphics of structural memberscan 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:TranslationRotationScaling
Dr. Ahmet Zafer Şenalp ME 521 2Mechanical Engineering Department,
GTU
8. 2D Coordinate Operations
• Translation:
A translation is moving every point a constant distance in a specified direction. It is one of the rigid motions.
Mathematically;
x' = x + Txy' = y + Ty
Here;x y : initial coordinatesx' y' : final coordinates.
2D TransformationsTranslation
Dr. Ahmet Zafer Şenalp ME 521 3Mechanical Engineering Department,
GTU
8. 2D Coordinate Operations
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 andx' = x + Txy' = y + TyThe new vertex coordinates of the triangle is:[(120,10) (160,10) (140,110)]
Öteleme örneği
2D TransformationsTranslationExample:
Dr. Ahmet Zafer Şenalp ME 521 4Mechanical Engineering Department,
GTU
8. 2D 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 cosay = r sina x’ = r cos (+ )
= r ( cos cos - sin sin ) = r cos cos - 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.
2D TransformationsRotation
P(x,y) noktasının saat yönünün tersi yönünde q açısıyla döndürülmesi
Dr. Ahmet Zafer Şenalp ME 521 5Mechanical Engineering Department,
GTU
8. 2D Coordinate Operations
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.
2D TransformationsRotationExample:
230,270,230,230,210,210
Dr. Ahmet Zafer Şenalp ME 521 6Mechanical Engineering Department,
GTU
8. 2D Coordinate Operations
• Scaling:
To change the scale of an object
x' = x Sxy' = y Sy
equations are used.
2D TransformationsScaling
Dr. Ahmet Zafer Şenalp ME 521 7Mechanical Engineering Department,
GTU
8. 2D Coordinate Operations
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)
2D TransformationsScalingExample:
Dr. Ahmet Zafer Şenalp ME 521 8Mechanical Engineering Department,
GTU
8. 2D 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.
2D TransformationsScalingExample:
Dr. Ahmet Zafer Şenalp ME 521 9Mechanical Engineering Department,
GTU
8. 2D 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);
İs obtained. If operation sequence is changed different result will be obtained. Concatenation is prefered as less arithmetic operation is necessary.
Concatenation
Rotation x' = y Translation x'' = x' - 80
y' = -x y'' = y'
Concatenation x'' = y - 80
y'' = -xor
Dr. Ahmet Zafer Şenalp ME 521 10Mechanical Engineering Department,
GTU
8. 2D Coordinate Operations
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
Matrix Representations
1
y
x
100
fed
cba
1
y
x
Dr. Ahmet Zafer Şenalp ME 521 11Mechanical Engineering Department,
GTU
8. 2D Coordinate Operations
Translation:
Rotation:
Scaling:
Matrix Representations
1
y
x
100
T10
T01
1
y
x
y
x
1
y
x
100
0θcosθsin
0θsinθcos
1
y
x
1
y
x
100
0S0
00S
1
y
x
y
x
Dr. Ahmet Zafer Şenalp ME 521 12Mechanical Engineering Department,
GTU
8. 2D Coordinate Operations
Consider scaling Sx = Sy = 2 ,then translate it with Tx = 10, Ty = 0
Scaling:
Translate:
Concatenation of Matrix Transformations
1
y
x
100
020
002
1
y
x
1
y
x
100
010
1001
1
y
x
Dr. Ahmet Zafer Şenalp ME 521 13Mechanical Engineering Department,
GTU
8. 2D 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.
Concatenation of Matrix Transformations
1
y
x
100
020
002
100
010
1001
1
y
x
1
y
x
100
020
1002
1
y
x
Dr. Ahmet Zafer Şenalp ME 521 14Mechanical Engineering Department,
GTU
8. 2D 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.
Rotation About an Arbitrary Point
1
y
x
100
10
01
1
y
x
y
x
P
P
1
y
x
100
0)cos()sin(
0)sin()cos(
1
y
x
θθ
θθ
Dr. Ahmet Zafer Şenalp ME 521 15Mechanical Engineering Department,
GTU
8. 2D Coordinate Operations
3. And finally we translate the point so that the origin is returned to (Px , Py):
These operations may be concatenated:
Rotation About an Arbitrary Point
1
y
x
100
10
01
1
y
x
y
x
P
P
1
y
x
100
10
01
100
0)cos()sin(
0)sin()cos(
100
10
01
1
y
x
y
x
y
x
P
P
θθ
θθ
P
P
1
y
x
100)sin(
))cos(1()cos()sin(
)sin(
))cos(1()sin()cos(
1
y
x
θP
θPθθ
θP
θPθθ
x
y
y
x
If Px, Py and are known three matrices can be multiplied to yield one transformation matrix
Dr. Ahmet Zafer Şenalp ME 521 16Mechanical Engineering Department,
GTU
8. 2D 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.
Efficiency
1
y
x
100
fed
cba
1
y
x
100
Dr. Ahmet Zafer Şenalp ME 521 17Mechanical Engineering Department,
GTU
8. 2D 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.
Efficiency
1
y
x
fed
cba
1
y
x
Dr. Ahmet Zafer Şenalp ME 521 18Mechanical Engineering Department,
GTU
8. 2D Coordinate Operations