You are on page 1of 28

Lecture 5

Editing and Transformation

Modeling
Model can be produced by the combination of entities that have been edited.
2D: circle, arc, line, ellipse 3D: primitive bodies, extrusion and revolved of a profile

Before editing

After editing

Before editing

After editing

(a)

Editing: surface and solid


Part to be edited Surface 1 Surface 2 Surface 1 Surface 2

Before Editing on surfaces

After

A B

B- A

A B

Cutting of Solid modell

Differences: 2D and 3D editing


(X cos - Y sin , x sin + Y cos ) A ( Axis A (X,Y) Plane

Center of rotation

(0,0)

2D: axis 3D: p plane


Z Y X Plane XY Plane YZ

2D: point 3D: axis


Center of rotation Rotation axis

Pl Plane ZX

Editing
Types of editing
Fillet Chamfer Trim Scale Mirror 3D: Boolean Operation Translation Rotation Copy Array Offset

Some editing preserves it original shape such hl length th and d angle l and d some dont. d t 2D editing is similar to 3D editing. Understanding CS is very important to find the relationship.

Example editing
A

Circle

Line

Spline

A Array 2D and 3D
Surface

X Y 3D ine

Z Y X Paksi Z

Paksi X

Paksi Y

Geometric Transformation
C Calculates l l t th the new coordinates di t when h transformation is applied to the geometric model. model The geometric model can be wireframe, surface and solid. solid Editing commands are in fact transformations e e.g g scale, scale mirror, mirror move.

Editing and transformation: relationship

A O
C

B
D

(XA+ X, YA+Y) (XC+ X, X YC+Y) (XB+X, YB+ Y) 2x x A A O (XB , YB ) X (XA, YA) Y (XC, Y C) Y X

Scaling points ABCD on point O Line is extended from OA

A O

(a) A A O B C D (c)

(b) B

Model Representation
Before applying the transformation matrices, the geometrical properties of the entities must be represented as matrices in its homogeneous coordinates in 2D or 3D. x1 y1 1 0 0 1 Rectangle x y 1 10 0 1 2 2 (0,0) ( , ) (10,0)(10,10)(0,10) ( , )( , )( , ) 10 10 1 x y 1 0 10 1 n n

x1 x 2 xn

y1 y2 yn

z1 z2 zn

1 1 1

Cube (0,0, 0) (10,0,0) (10,10, 10)

0 0 0 1 10 0 0 1 10 10 10 1

Convert to their homogeneous representation


(30 20) (30,20) (30,30)

Y (0,10,0)

(10,20)

(20,20)

(A)

(0,1,1) (1,1,1) ( , , )

(0,0,10) Z

(10,0,0) X

(0,0,1) (0,1,0) Z Y (1,1,0)

(B)

(0,0,0) X (1,0,0)

(C) ( )

Applying transformation matrices


x1' ' x2 ' xn 1 x1 y '2 1 x2 = y 'n 1 xn y 1' 1 y 2 1 [ ] 2D y n 1 y1

x1' ' x2 ' xn

y 1' y '2 y 'n

z 1' z '2 z 'n

1 x1 1 x2 = 1 xn

y1 y2 yn

z1 z2 zn

1 1 [ ] 3D 1

Translation
2D Translation

0 0 1 [TR ] = 0 1 0 x y 1
0 0 0 1
Component-wise addition of vectors x = x + dx y = y + dy z = z + dz To move polygons: translate vertices (vectors) and redraw lines between them Preserves lengths and angles Does not require reference point

0 0 1 0 3D Translation 1 0 [TR ] = 0 0 1 x y z

Rotation
Rotation 2D

cos [R ] = sin 0

sin i cos 0

0 0 1
Rotation of vectors through an angle x = x cos y sin y = x sin + y cos y Preserves lengths and angles Point of rotation point (0,0)

A (X cos - Y sin , x sin + Y cos ) A (X,Y)

Center of rotation

(0,0)

Rotation at other point than origin point


Let L t say that th t the th center t of f rotation t ti is i (x1, ( 1 y1). 1) Translation has to be carried before and after rotation Procedure 1. Convert the (x1, y1) to (0,0) by applying translation x = -x1 and y= -y1. 2. Apply the rotation matrix 3 Convert the (0,0) 3. (0 0) to its original point (x1, (x1 y1) by applying translation x = x1 and y = y1.

x1' ' x2 ' xn

y 1' 1 x1 ' y 2 1 x 2 = ' y n 1 xn

y1 1 0 0 1 1 0 0 y 2 1 [ ] 0 1 0 0 1 0 R x1 y1 1 x1 y1 1 y n 1

3D Rotation
0 1 0 cos [R X ] = 0 sin 0 0 0 sin cos 0 0 0 0 1
cos 0 [R Y ] = sin 0
sin cos 0 0 0 0 0 0 1 0 0 1

0 sin 1 0 0 0 cos 0

0 0 0 1

Axis of rotation: x
cos sin [R Z ] = 0 0

Axis of rotation: y

Axis of rotation: z p axis: apply pp y translation If axis of rotation other than specified before and after 3D rotation is applied

Scaling 2D and 3D
S y [R ] = 0 0
O A C B D

0 Sy 0

0 0 1

S x 0 [S ] = 0 0

0 Sy 0 0

0 0 SZ 0

0 0 0 1

Scaling points ABCD on point O 2x Line is extended from OA x A O O A A

(a) A A A O B C D (c)

(b) B B

Component-wise scalar multiplication of vectors x = Sx x y = Sy y Does not preserve lengths Does oes not ot p preserve ese e angles a g es (except (e cept when scaling is uniform) Point of reference for scaling is (0,0) 2D and (0,0,0) 3D

Scaling at other than (0,0) or (0,0,0), apply translation before and after applying scaling transformation

Foundation of transformations
Similar method can be applied on other transformation such as shear, reflection etc. Important, if the transformation q point (2D), p ( ), axis (2D ( & 3D) ) requires and plane (3D) at the origin CS. Translation must be applied before and after applying the respective transformation.

Applying transformation composite matrices


Do this transformation on screen
1. 2. 3. 1. 2. 3. Draw rectangle any size Translate dx = 6 Rotate it by 450 The same rectangle Rotate it 450 Translate dx = 6

Q: Do both rectangles overlapping each other? Why?

C Composite it T Transformations f ti
Y
6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10

Translation Rotation
Y
6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10

Rotation Translation

Composite Transformation
[C ] = [1 ][2 ][3 ]...[n ]

[X ] = [X ][ ]
' C

Composite Transformation: C Combination bi ti of f multiple lti l t transformations f ti must be in sequence.

Mapping
Mapping finds the relationship between two coordinate system

a11 a21 [MP ] = a12 a22 x y


X

0 0 1

a11 a21 a a [MP ] = 12 22 a13 a23 x y

a31 a32 a33 z

0 0 0 1

P
Y

(X1,Y1) X X Y

Mapping combines the rotation and translation. 2D mapping: i a11 to a22: TR 3D mapping a11 to a33: TR-X R X, TR-Y R Y and TR-Z RZ

Mapping: example
Write the composite transformation for mirroring square ABCD using axis ( 300 slope line through (0,2))
Axis 30 30 D (0,2)

Solution 1
Y Y X D (0,0) Y Y B X D (0,0) C C

A X (a) Translation

B X

1. 2. 3. 4 4. 5.
B

Translation Rotation Mirror R t ti Rotation Translation

(b) Rotation

B C A Y D X D (0,0) C A

B
A

C
D

D X D C
Y

(0,0)
A X B

A (c) Mirror

A (d) Rotation

(0,0) (e) Translation

Solution 1 Matrices
[M ] = [TR1 ][R1 ][MR ][R 2 ][TR 2 ]
1 0 0 0 1 0 , [TR1 ] = 0 2 1 1 0 0 , [MR ] = 0 1 0 0 0 1 1 0 0 [TR 2 ] = 0 1 0 0 2 1 cos(300 ) sin( 300 ) 0 [R1 ] = sin(300 ) cos(300 ) 0 2 0 1 cos(300 ) sin(300 ) 0 0 0 [R 2 ] = sin( 30 ) cos( 30 ) 0 , 2 0 1

Solution 2
1. M 1 Mapping i 1 2. Mirror 3. Mapping 2
B C A Y X D Y Y X (0,0) X (a) Mapping 1 A B Y

B C C A D D
D X D Y C

20 Y X X

Y Y A (0,0) X B

(c) Mapping 2
(0,0)

(b) Mirror

Solution 2 Matrices
[M ] = [MP1 ][MR ][MP 2 ]
cos(300 ) sin( 30 0 ) 0 [MP1 ] = sin(300 ) cos(300 ) 0, 2 cos(600 ) 2 sin(60 0 ) 1 cos(30 0 ) sin(300 ) 0 0 0 [MP 2 ] = sin( 30 ) cos( 30 ) 0 0 0 2 cos( (60 ) 2 sin( (60 ) 1 1 0 0 0 1 0 [MR ] = 0 0 1

Discuss the following problem


Square A(10 A(10,10), 10) B(20 B(20,10), 10) C(20,20) C(20 20) D(10,20) Write down the matrices involved only without mathematically solving them to establish the following transformation.
X axis ( Y = 0) Y = -10 Y = -X X Y = -X -5

Application of transformation
Movement of mechanism

Modeling

Head Shaft Point


composition

decomposition

Aids realism in computer graphic: projection

You might also like