Sie sind auf Seite 1von 66

TRANSFORMATIONS

Transformation
"Transformation" is the elementary term
used for a variety of operation such as
translation, rotation, scaling, reflection,
shearing etc.
CAD requires transformations from
conceptual design and layout, through
detailed engineering and analysis of
components to definition of manufacturing
methods.
Transformation
Every aspect of modeling in CAD is
dependent on the transformation to view
model from different directions we need to
perform rotation operation.
To move an object to a different location
translation operation is done.
Similarly Scaling operation is done to
resize the object.
Coordinate Systems
Conventions
Right-hand side system

y y

z
x

z x

( z out of page ).
Model Coordinate System
MCS is defined as the reference space of
the model with respect to which all the
model geometrical data is stored.

The origin of MCS can be arbitrary chosen


by the user.

Every object have its own MCS relative to


which its geometrical data is stored.
World Coordinate System
World Coordinate System
Multiple objects in the same working
space, then there is need of a World
Coordinate System which relates each
MCS to each other with respect to the
orientation of the WCS.
Screen Coordinate System
Screen Coordinate System
SCS is defined as a two dimensional
device-dependent coordinate system.
Origin is usually located at the lower left
corner of the graphics display as shown in
the picture below.
A transformation operation from MCS
coordinates to SCS coordinates is
performed by the software before
displaying the model views and graphics.
2D Translations.

Point P defined as P(x, y),


translate to Point P(x, y) a distance dx parallelto x axis, d y parallelto y
axis.
x x d x y y d y
Define the column vectors
x x dx P

P ,P ,T P
y y dy
Now
P P T
2D Translation
Repositioning an object along a straight line path from
one co-ordinate location to another
(x,y) (x,y)
To translate a 2D position, we add translation distances tx
and ty to the original coordinates (x,y) to obtain the new
coordinate position (x,y)
x= x + tx , y= y + ty

Matrix form y

P P T x
2D Translation
Moving a polygon from position (a) to position (b)
with the translation vector (-5, 10), i.e.
5
T
0

y y
20 20
15 15
10 10
5 5

5 10 15 20 x 5 10 15 20 x
(a) (b)
2D Rotation about the origin.


P(x,y)

P(x,y)
r

r
x
2D Rotation about the origin.
Repositioning an object along a circular path in the xy-plane

x r.cos( ) r.cos.cos r.sin .sin


y
y r.sin( ) r.cos.sin r.sin .cos

P(x,y)

x r.cos
P(x,y)
r

y r.sin
r
y


x
x
2D Rotation about the origin.

x r.cos( ) r.cos.cos r.sin .sin


y r.sin( ) r.cos.sin r.sin .cos

x r.cos
y r.sin
Given us

x x.cos y.sin
y x.sin y.cos
2D Rotation about the origin.

x x.cos y.sin
y x.sin y.cos

Rewriting in matrix form gives us :

x cos sin x
sin .
cos y
y

cos sin
Define the matrix R P R P

cos
sin ,
2D Rotation about a Pivot
position
Rotating about pivot position (xr, yr)
y

(x,y)
r

r
(x,y)
yr
xr x

x xr (x xr ) cos ( y yr ) sin

y yr (x xr ) sin ( y yr ) cos
2D Scaling from the origin.
Point P defined as P(x, y),
Perform a scale (stretch) to Point P(x, y) by a factor s x along the x axis,
and s y along the y axis.
x sx.x, y s y .y
Define the matrix P
P
sx 0
S

Now
0 sy

x s x 0 x
P S P y 0 s y y
.
o
r
2D Scaling
Altering the size of an object. Sx and Sy are the
scaling factors. If Sx = Sy then uniform scaling.
x xSx y

y ySy
Matrix form x
Sx = Sy =
x S x 0 x


y 0 S y y

P S P
x x
Sx = Sy =
Reduced in size and moved
closer to the origin
2D Scaling relative to Fixed
point
Scaling relative to fixed point (xf, yf)

x x f (x x f )S x y P1
P1
(xf , yf)
y y f ( y y f )S y P2 P2
P3
OR P3

x xSx x f (1 S x ) Sx = , Sy = x

y ySy y f (1 S y )

where the additive terms xf(1-Sx) and yf(1-Sy) are


constants for all points in the object.
Transformations.
Translation.
P=T + P
Scale
P=S P
Rotation
P=R P
We would like all transformations to be multiplications
so we can concatenate them express points in
homogenous coordinates.
Homogeneous coordinates
If we represent (x,y,W) in 3-space, all triples
representing the same point describe a line passing
through the origin.
If we homogenize the point, we get a point of form (x,y,1)
homogenised points form a plane at W=1.

W P

W=1 plane

Y
Translations in homogenised
coordinates

Transformation matrices for 2D translation are now 3x3.

x 1 0 d x x x x d x
y 0 . y
1 d y y y d y
1
0 0 1
1
11
Concatenation.

We perform 2 translations on the same point:

P P T (dx1, d y1 )
P P T (d x 2 , d y 2 )
P P T (dx1, d y1 ) T (d x 2 , d y 2 ) P T (dx1 d x 2 , d y1 d y 2 )

So we expect :
T (dx1, d y1 ) T (d x 2 , d y 2 ) T (dx1 d x 2 , d y1 d y 2 )
Concatenation.

The matrix product T (d x1, d y1 ) T (d x 2 , d y 2 ) is :


1 0 d x1 1 0 d x 2 1 0 d x1 d x 2
0 1 d . 0 1 d 0 1 d d
y1 y2 y1 y2

0 0 1 0 0 1 0 0 1


Matrix product is variously referred to as compounding,
concatenation, or composition.
This single matrix is called the Coordinate Transformation Matrix or
CTM.
Homogeneous form of scale.

Recall the (x,y) form of Scale : sx 0


S (sx , s y )
sy

0
In homogeneous coordinates

s x 0 0
S(s x , s y ) 0 s y 0

0 0 1
Concatenation of scales.

The matrix product S(sx1, sy1) S(s x2 , sy 2 ) is :


sx1 0 0 sx20 0 sx1 s x2 0 0
0
sy1 0 . 0
sy2 0 0 sy1 s y2 0


0 0 1 0 0 1 0 0 1
Onlydiagonalelementsin the matrix - easy to multiply!
Homogeneous form of rotation.

x cos sin 0 x
y sin cos 0 . y

1 0 0 1
1

For rotation matrices,


R1( ) R( ).
Rotation matrices are orthogonal, i.e :
R1( ) RT ( )
Example: 2D Geometric
Transformation
Modeling
Coordinates
Again?

World Coordinates
Example: 2D Geometric
Transformation
Modeling
Coordinates
Scale
Translate

Scale
Rotate
Translate
World Coordinates
Matrix Representation
Use 33 matrices to combine transformations
x 1 0 tx x

y 0 y
Translation 1 ty
1 0 0 1 1

x cos sin 0 x
Rotation y sin cos 0 y

1 0 0 1
1

x S x 0 0 x

0 y
Scaling y
Sy 0
1 0 1
0 1
Inverse Transformations

1 0 tx
Translation T 1
0 1 t y

0 0 1

cos sin 0
Rotation R1
sin
0

0
cos 1

0
1S x 0
0
Scaling S 1
0 1
Sy
0

0 0 1

Example
Consider the line with endpoints (10, 10) and (30, 25).
Translate it by tx = -20, ty = -10 and then rotate it by = 90.
y
(30, 25)

(10, 10)

Right-to-left

x cos sin 0 1 0 20 x
y 90 90 cos 0 0 1 10 y
sin 90
1 0 90 0 1 0 1
0 1
Solution
x cos sin 0 1 0 20 x
y 90 90 cos 0 0 1 10 y
sin 90
1 0
90 0 1 0 0 1 1

0 1 0 1 0 20 x
1
0 0 0
1 10 y



0 0 1 0 0 1 1

0 1 10 x

1 0 20 y


y
0 1 (30, 25)
0 1

(10, 10)

x
Solution (continue)
x 0 1 10 x y

y 1
0 20 y


(30, 25)
1 0 1
0 1 (-15, 10)
(10, 10)
x
(0, -10)
Point (10, 10)
x 0 1 10 10 0

y 1 0 20 10 10


1 0 1
0 1 1
Point (30, 25)

x 0 1 10 30 15

y 1 0 25 10
20

1 0 1 1 1
0
Reflection
Relative to the coordinate origin
y
x 1 0 0 x

y 0 1 0 y

1 0 0 1 x
1

Same as a rotation with 180

With respect to the line y = x


y y=x
x 0 1 0 x

y 1
0 0 y
1 0 0 1
1
x
3D transformations
3D Transformations
Positioning of a rigid object in the 3D space: six parameters
Three coordinates of a reference point
Three angles of Euler

xyz initial coordinate system


XYZ rotated coordinate system
N line of nodes intersection
of xy and XY planes
http://en.wikipedia.org/wiki/Euler_angles
3D Translation
Repositioning an object along a straight line path from
one co-ordinate location to another
(x,y,z) (x,y,z)
To translate a 3D position, we add translation distances tx
ty and tz to the original coordinates (x,y,z) to obtain the
new coordinate position (x,y)
x= x + tx , y= y + ty , z= z + tz

Matrix form (4 4) y

x 1 0 0 tx x
0
y 1 0 t y y T(tx, ty, tz)
z 0 0 1 tz z
1 0 1 x
0 0 1
z
P T (tx ,t y ,tz )P
3D Rotation
z-axis
The 2D z-axis rotation equations are extended to 3D.
y
x x cos y sin
y x sin y cos
z z x
z
Matrix form

x cos sin 0 0 x y
sin
y cos 0 0 y
z 0 0 1 0 z
1 0 1 1
0 0 x
P Rz ( )P z
3D Rotation
x-axis
y
y y cos z
sin z y sin
z cos x x
x

z
Matrix form

x 1 0 0 0 x
0
y cos sin 0y
z 0 sin 0 z
1 0 cos 1 1

0 0
P Rx ( )P
3D Rotation
y-axis
y
z z sin x
cos x z sin
x cos y y
x

z
Matrix form

x cos 0 sin 0 x
0
y 1 0 0y
z sin 0 cos 0 z
1 1 1
0 0 0
P Ry ( )P
3D transformations

.
Y
P1(X1,Y1,Z1)

.
Z (to the back)
P1(X1,Y1,Z1)

Right-hand system
X
O
3D transformations
Matrix representation
4 x 4 matrices for 3-D, analogous to 3 x 3 matrices
for 2-D using homogeneous coordinates

Wx x
x Wy x
y ; usual notation W 1: y
y
Wz z
z
z


W 1
Each point in 3D space a line throught the origin in 4D space
3D Rotation
Elementary rotation around X-axis
X = X
Y = Y cos() - Z sin()
Z = Y sin() + Z cos()
Can be represented in matrix form as
x' 0 0 0 x
y'1 cos 0 y

0
z' sin sin 0 z
0 cos
1 11
0 0 0
RX ()
3D Rotation
Similarly for rotations around other axes
1 0 0 0
0 cos 0
RX ( ) =
0 sin sin 0
cos

0 0 0
1
cos 0 sin cos sin 0
0 0 0 sin
0

RY () = sin
0 1 0 0 RZ () = 0 cos 0 0

0
0 1 0
0 1 1
cos 0 0
0 0
3D Scaling
x xsx y
y ysy
z zsz
x

Matrix form z

x sx 0 0 x

y 0 0
0 y
z 0 sy 0 0 z

1 0 0 sz
1 1
0 0
P S(sx , sy , sz )P
3D Shear

Shear around the Z-axis


X = X + HX Z
Y = Y + HY Z
Z =Z
x' 1 0 Hx 0 x
y' 1 Hy 0 y

z'0 0 1 0 z
10 1

0 0 0 1

Shear around the X-axis and Y-axis have a


similar form
Other 3D Transformations
Reflection z-axis
y
x 1 0 0 0 x

y 0 1 0 0 y

z 0 0 1 0 z
1 0 0 0 1 1 x

z

Shears z-axis
x 1 0 shx 0 x
y 0
1 shy 0 y

z 0 0 1 0 z
1 0 1 1
0 0
Case Study: Computer
Graphics in Automotive Design
In this case study, we explore how we take a
three-dimensional image and render it
effectively in two dimensions.
This type of operation is very important in
automotive design allows engineers to
experiment with images on a computer
screen instead of using a three dimensional
model of the automobile.
We will first discuss how to convert a three-
dimensional image to a two-dimensional
picture using a perspective projection.
Perspective projection
We are given the center of projection (b;
c; d) and some data point (x; y; z).
We wish to find the point (x; y; 0) in the xy
plane which lies on the same line as (b; c;
d) and (x; y; z) space.
To find the coordinates x and y, we will
need to find the equation of the line
through (b; c; d) and (x; y; z).
We will then plot the two points X* Y* in
two dimensional point
Then we are looking for the equation of the line through p parallel to v, which may be
written as
THANK YOU

Das könnte Ihnen auch gefallen