2d transformations (contd.)

21
1 2D TRANSFORMATIONS (Contd.) Sequence of operations, Matrix multiplication, concatenation, combination of operations AML710 CAD LECTURE 5 Types of Transformation Affine Map: A map φ that maps E 3 into itself is called an affine Map if it leaves barycentric conditions invariant. If Then, Most of the transformations that are used to position or scale an object in CAD are affine maps. The name was given by L. Euler and studied systematically by A. Mobius Euclidian Maps: Rigid body motions like rotation and translation where lengths and angles are unchanged are called Euclidian maps. This is a special case of affine maps 3 , , E a x a x j j j = β 3 , E a x a x j j j = φ φ φ β φ

Upload: doanliem

Post on 09-Dec-2016

267 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 2D TRANSFORMATIONS (Contd.)

1

2D TRANSFORMATIONS(Contd.)

Sequence of operations, Matrix multiplication, concatenation,

combination of operations

AML710 CAD LECTURE 5

Types of TransformationAffine Map: A map φ that maps E3 into itself is called an

affine Map if it leaves barycentric conditions invariant.If Then,

Most of the transformations that are used to position or scale an object in CAD are affine maps. The name was given by L. Euler and studied systematically by A. Mobius

Euclidian Maps: Rigid body motions like rotation and translation where lengths and angles are unchanged are called Euclidian maps. This is a special case of affine maps

3, , Eaxax jjj ∈=∑β

3, Eaxax jjj ∈=∑ φφφβφ

Page 2: 2D TRANSFORMATIONS (Contd.)

2

Transformation Groups and Symmetries

Affine transformations are classified (Felix Klein) as follows

Similarity Groups: Rigid motion and scalingEg: Congruent, similarSymmetry Groups:Rotation, Reflection, Translation1. No translation and no reflection – Circle groupEg: a gear wheel2. No translation and at least one reflection –

Dihedral group3. Translation along one direction4. Translation along more than one direction

Homogeneous coordinates of verticesA point in homogeneous coordinates (x, y, h), h ≠ 0, corresponds to the 2-D vertex (x/h, y/h) in Cartesian coordinates. Conceive that the Cartesian coordinates axes lies on the plane of h = 1. The intersection of the plane and the line connecting the origin and (x, y, h) gives the corresponding Cartesian coordinates.

y

w

xh = 0

(x, y, h)

h = 1

(x/h, y/h, 1)x

y

Page 3: 2D TRANSFORMATIONS (Contd.)

3

For example, both the points (6, 9, 3) and (4, 6, 2) in the homogeneous coordinates corresponds to (2, 3) in the Cartesian coordinates.

Conversely, the point (2, 1) of the Cartesian corresponds to (2, 1, 1), (4, 2, 2) or (6, 3, 3) of the homogeneous system

y

h

xh = 0

(4, 2, 2)

h = 1

(2, 1, 1)x

y

6, 3, 3)

RotationConsider the following figure where a position vector p(x,y)

which makes an angle φ to x-axis after transformation to p’(x’,y’) makes an angle φ+θ degrees.

P= [x y] = [rcosφ rsinφ]P’= [x’ y’] = [rcos(φ+θ ) rsin(φ+θ )]= [r(cosφcosθ - sinφsinθ) r(cosφsinθ+ sinφcosθ) ]

Using the definition of x=rcosφ and y=rsinφ, we can writeP’= [x’ y’] = [x cosθ – y sinθ x sinθ +y cosθ ] or the transformation

matrix is

θ

P’(x’,y’)

P(x,y)

φ

[ ][ ] [ ] ⎥⎦

⎤⎢⎣

⎡−

=θθθθ

cossinsincos

yxTX

Page 4: 2D TRANSFORMATIONS (Contd.)

4

Some Common Cases of Rotation

Rotation of 90° counter clockwise about the origin

Rotation of 180° counter clockwise about the origin

Rotation of 270° counter clockwise about the origin

In all the above cases det[T]=1

[ ] ⎥⎦

⎤⎢⎣

⎡−

=⎥⎦

⎤⎢⎣

⎡−

=0110

cossinsincos

θθθθ

T

[ ] ⎥⎦

⎤⎢⎣

⎡−

−=⎥

⎤⎢⎣

⎡−

=10

01cossinsincos

θθθθ

T

[ ] ⎥⎦

⎤⎢⎣

⎡ −=⎥

⎤⎢⎣

⎡−

=0110

cossinsincos

θθθθ

T

Reflection- Special case of RotationReflection is a special case of rotation of 180°

about a line in xy plane passing through the origin. Eg about y=0 (x-axis)

About x=0 (y-axis)

About the lines x=y and x-y respectively are:

[ ] ⎥⎦

⎤⎢⎣

⎡−

=10

01T

[ ] ⎥⎦

⎤⎢⎣

⎡−=

1001

T

[ ] ⎥⎦

⎤⎢⎣

⎡=

0110

T [ ] ⎥⎦

⎤⎢⎣

⎡−

−=

0110

T

Page 5: 2D TRANSFORMATIONS (Contd.)

5

Reflection- PropertiesIf two pure reflections about a line passing through

the origin are applied successively the result is a pure rotation.

The determinant of a pure reflection matrix is -1

[ ] ⎥⎦

⎤⎢⎣

⎡−=

1001

T

Properties of transformation MatricesDet[T]=? In case of a) rotation, b) reflection.What is the geometrical interpretation of inverse of

[T]?Show that TT-1 = [I]

Thus for a pure rotation (det[T]=1) the inverse of T is its transpose

[ ] ⎥⎦

⎤⎢⎣

⎡−

=θθθθ

cossinsincos

T

[ ] TTT =⎥⎦

⎤⎢⎣

⎡ −=⎥

⎤⎢⎣

⎡−−−−−

=−

θθθθ

θθθθ

cossinsincos

)cos()sin()sin()cos(1

Page 6: 2D TRANSFORMATIONS (Contd.)

6

Show that the following transformation matrix gives a pure rotation

⎥⎥⎥⎥

⎢⎢⎢⎢

+−

+−

++−

=

2

2

2

22

2

11

12

12

11

][

tt

tt

tt

tt

T

11

21

211

11]det[ 222

2

2

2

=⎟⎠⎞

⎜⎝⎛+

⎟⎠⎞

⎜⎝⎛+−

−⎟⎟⎠

⎞⎜⎜⎝

⎛+−

⎟⎟⎠

⎞⎜⎜⎝

⎛+−

=tt

tt

tt

ttT

Example

Example

A A unit square is transformed by a 2×2 transformation matrix. The resulting position vectors are:

Determine the transformation matrix used.

Ans:

⎥⎥⎥⎥

⎢⎢⎢⎢

=′

16483200

][x

⎥⎦

⎤⎢⎣

⎡=∴

⎥⎥⎥⎥

⎢⎢⎢⎢

=

⎥⎥⎥⎥

⎢⎢⎢⎢

++=⎥

⎤⎢⎣

⎥⎥⎥⎥

⎢⎢⎢⎢

==′1632

][;

1648320000

10110100

]][[][ T

dcdbca

badcba

TXx

Page 7: 2D TRANSFORMATIONS (Contd.)

7

Example

Show that the shear transformation in x and y directions together is not the same as shear along x followed by shear along y?

Ans: ⎥⎦

⎤⎢⎣

⎡≠⎥

⎤⎢⎣

⎡ +=⎥

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡1

11

1101

101

cb

cbbc

cb

⎥⎦

⎤⎢⎣

⎡≠⎥

⎤⎢⎣

⎡+

=⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡1

11

110

1101

cb

bccbb

c

Example Problem• Consider a triangle whose vertices are (2 2), (4 2) and (4 4). Find the

concatenated transformation matrix and the transformed vertices for rotatation of 90 about the origin followed by reflection through the line y = -x. Comment on the sequence of transformations.

⎥⎥⎥

⎢⎢⎢

−−−

=⎥⎦

⎤⎢⎣

⎡−

⎥⎥⎥

⎢⎢⎢

⎡=⎥

⎤⎢⎣

⎡−

−⎥⎦

⎤⎢⎣

⎡−

⎥⎥⎥

⎢⎢⎢

⎡==

442422

1001

442422

0110

0110

442422

}}[[}}[}[[ 21 TXTTX

For seeing the effect of changing the sequence of operations let us reverse the order, i.e, first reflection and then rotation.

⎥⎥⎥

⎢⎢⎢

−−−

=⎥⎦

⎤⎢⎣

⎡−

⎥⎥⎥

⎢⎢⎢

⎡=⎥

⎤⎢⎣

⎡−⎥

⎤⎢⎣

⎡−

⎥⎥⎥

⎢⎢⎢

⎡==

442422

1001

442422

0110

0110

442422

}}[[}}[}[[ 12 TXTTX

Page 8: 2D TRANSFORMATIONS (Contd.)

8

Example Problem: Solution

Conduct a combination of transformations in sequence

Translate the right-angle vertex to the origin (Tx = -1, Ty = -1)

Rotate 45o (π/4 radian) sin π/4 = cos π/4 = 0.7071

(1,1)(5,1)

(1,3)

(2.8,2.8)(-1.4,1.4)

(0,0) (4,0)

(0,2)

.100

1001

'''

⎥⎥⎥

⎢⎢⎢

⎥⎥⎥

⎢⎢⎢

⎡=

⎥⎥⎥

⎢⎢⎢

wyx

TT

wyx

y

x

⎥⎥⎥

⎢⎢⎢

⎥⎥⎥

⎢⎢⎢

⎡ −=

⎥⎥⎥

⎢⎢⎢

'''

1000cossin0sincos

"""

wyx

wyx

θθθθ

Page 9: 2D TRANSFORMATIONS (Contd.)

9

100

cossincossinsincossincos

1001001

1000cossin0sincos

'''

1000cossin0sincos

"""

⎥⎥⎥

⎢⎢⎢

⎥⎥⎥

⎢⎢⎢

⎡+−−

=

⎥⎥⎥

⎢⎢⎢

⎥⎥⎥

⎢⎢⎢

⎥⎥⎥

⎢⎢⎢

⎡ −=

⎥⎥⎥

⎢⎢⎢

⎥⎥⎥

⎢⎢⎢

⎡ −=

⎥⎥⎥

⎢⎢⎢

wyx

TTTT

wyx

TT

wyx

wyx

yx

yx

y

x

θθθθθθθθ

θθθθ

θθθθ

The computation of [ ] from [ ] [ ] is called matrix multiplication. The general form is:

A sequence of transformations can be lumped in a single matrix via matrix multiplications

⎥⎦

⎤⎢⎣

⎡++++

=⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡dhcfdgcebhafbgae

hgfe

dcba

Scaling relative to a fixed point

1. Translate the point(-m, -n) to the origin2. Scale the object by Sx, Sy scale factors3. Translate the point back (m, n)

(m, n)

[ ] [ ] [ ][ ]tt TSTT 1−=

[ ]100

1001

1000000

1001001

⎥⎥⎥

⎢⎢⎢

⎡−−

⎥⎥⎥

⎢⎢⎢

⎥⎥⎥

⎢⎢⎢

⎡= n

mSy

Sxnm

T Column Vectors

Page 10: 2D TRANSFORMATIONS (Contd.)

10

Rotation about an arbitrary point

(m, n)

[ ] [ ][ ][ ] 1−= tt TRTT

[ ]

1010001

1000cossin0sincos

1010001

⎥⎥⎥

⎢⎢⎢

⎥⎥⎥

⎢⎢⎢

⎡−

⎥⎥⎥

⎢⎢⎢

−−=

nmnmT θθ

θθRow Vectors

Rotation about an arbitrary point1. Translate the point(-m, -n) to the origin2. Rotate the object about the origin by θo

3. Translate back (m,n)

Ex: Center of an object (4,3) , rotate it about the center by 90o CC

P =[x y h]

[ ] [ ][ ][ ] 1−= tt TRTT

[ ]⎥⎥⎥

⎢⎢⎢

⎥⎥⎥

⎢⎢⎢

⎡−

⎥⎥⎥

⎢⎢⎢

−−

1100101

710

117001010

1 yx

ORyx

P(m, n)

[ ]

1010001

1000cossin0sincos

1010001

⎥⎥⎥

⎢⎢⎢

⎥⎥⎥

⎢⎢⎢

⎡−

⎥⎥⎥

⎢⎢⎢

−−=

nmnmT θθ

θθ

Page 11: 2D TRANSFORMATIONS (Contd.)

11

Reflection O(3)Reflection is a special case of rotation SO(3) when angel of rotation is 180° about an axis in the plane

y =mx+b

)(tan 1 m−=θθ

b

[ ]

100010001

⎥⎥⎥

⎢⎢⎢

⎡−=T

1)180cos(,0)180sin( −==

Reflection about an arbitrary line1. Translate (0, -b) so that the line

passes through the origin2. Rotate the line about the x axis by -θo

3. Reflect object about the x axis4. Rotate back the line by θo

5. Translate back (0,b)

y =mx+b

)(tan 1 m−=θ

θb

[ ] [ ][ ][ ][ ] [ ] 11 −−= trrt TTRTTT

[ ]

100210001

10005/25/105/15/2

100010001

10005/25/105/15/2

100210

001

⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡ −−−−=T

)4(21 += xy

⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡=−

1115/65/145/125/225/285/14

111664242

1005/165/35/45/85/45/3

Ex: Reflect triangle (2,4),(4,6),(2,6) about line

Alternate Method?

Page 12: 2D TRANSFORMATIONS (Contd.)

12

Mid-point TransformationConsider a straight line between A(x1,y1) and B(x2,y2). Let us try to transform this line using a general a 2×2 transformation matrix

B

M

EB*A*

F’

M’

A⎥⎦

⎤⎢⎣

⎡=

dcba

T ][

⎥⎦

⎤⎢⎣

⎡=⎥

⎤⎢⎣

⎡++++

=⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡=⎥

⎤⎢⎣

⎡=⎥

⎤⎢⎣

⎡*2

*2

*1

*1

2222

1111

22

11][**

yxyx

dybxcyaxdybxcyax

dcba

yxyx

TBA

BA

[ ]

)1(2222

2222

21212121

22112211*2

*1

*2

*1**

⎥⎦⎤

⎢⎣⎡ +

+++

++

=

⎥⎦⎤

⎢⎣⎡ ++++++

=⎥⎦

⎤⎢⎣

⎡ ++=

yydxxbyycxxa

dybxdybxcyaxcyaxyyxxyx mm

[ ] )2(222222

'' 212121212121⎥⎦⎤

⎢⎣⎡ +

+++

++

=⎥⎦

⎤⎢⎣

⎡⎥⎦⎤

⎢⎣⎡ ++

=yydxxbyycxxa

dcbayyxxyx mm

Mid-point TransformationFrom (1) and (2) we can conclude that by recursivelycontinuing this process, we will cover allpoints on the line AB and hence their images on A*B* by corresponding map.

But a general proof of end points transformation actually transforms the whole line can be given usign the section formula. Any point mthat divides the line AB in the ratio p:q can be given as:

Needless to say that the same is applicable to A*B*. The special case of mid point transformation occurs when p:q=1.

B

M

EB*A*

F’

M’

A

)(1 abm qpqp

++

=

Page 13: 2D TRANSFORMATIONS (Contd.)

13

Transformation of intersecting linesWhen two intersecting lines aretransformed usinggeneral 2x2 transformation matrix the resulting lines arealso intersectingConsider 2 intersection lines

The point of intersection:

Transformed point of intersection:

B

F

EB’A’

F’

E’

A

[ ] ⎥⎦

⎤⎢⎣

⎡−

−+−−

−+−=

12

122121

12

122121'' )()()()(mm

mbmbdbbbmm

mbmbcbbayx ii

22

11

bxmybxmy

+=+=

[ ] [ ]

[ ] ⎥⎦

⎤⎢⎣

⎡⇒

⎥⎦

⎤⎢⎣

⎡−−

−−

==

dcba

X

mmmbmb

mmbbyxX

i

iii12

1221

12

21

Transformation of intersecting linesObserve these points In the last slide1. A pair of non-perpendicular lines

get transformed to perpendicular lines

2. By inverse T-1 a pair of perpendicularlines can get transformed to non-perpendicular lines

3. Such a result can have disastrous effecton the resulting geometry

B

F

EB’A’

F’

E’

A

Page 14: 2D TRANSFORMATIONS (Contd.)

14

Transformation of two parallel linesWhen two parallel lines are transformed using general 2x2

transformation matrix the resulting lines remain parallel

Consider 2 lines parallel to each other between the end points A(x1,y1),B(x2,y2) and CD. Since they are parallel the slope is the same given by

12

12

xxyy

m−−

=

[ ][ ] ⎥⎦

⎤⎢⎣

⎡++++

=⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡=

2211

2211

21

21

dybxdybxcyaxcyax

yyxx

dbca

XT

)()()()(

)()()()(

1212

1212

1122

1122

yycxxayydxxb

cyaxcyaxdybxdybx

m−+−−+−

=+−++−+

=′

cmadmb

xxyy

ca

xxyy

dbm

++

=

−−

+

−−

+=′

)()()()(

12

12

112

2

Intersecting lines and rigid body transformations When do perpendicular lines transform as perpendicular lines?Consider the scalar(dot) and vector products of two vectors as follows

Let us now transform these vectors by general 2x2 T and find dot and cross products again

We require for magnitude and angle to remain unchanged

θcos2121212.1 VVyVyVxVxVVV =+=

( ) θsin21212121 kVVkyVyVxVxVVVvv

=−=×

⎥⎦

⎤⎢⎣

⎡++++

=⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

yxyx

yxyx

xy

xx

dVbVdVbVcVaVcVaV

VVVV

dbca

2211

2211

21

21

θcos21)2121)((21)22

(21)22

( VVxVyVyVxVbdacyVyVdcxVxVba ′′=++++++

θsin21)1221)(( kVVkyVxVyVxVbcadrr

′′=−−

[ ][ ] [ ][ ] [ ]ITTTTORbcadbdacdcba T ==+=−=+=+=+ −11;0;12222

Page 15: 2D TRANSFORMATIONS (Contd.)

15

Transformation of Unit square and areaObserve unit square being scaled and sheared along x

and y axes simultaneously

A B

D C

A’

D’

B’

C’

⎥⎦

⎤⎢⎣

⎡++

=⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡=′⎥

⎤⎢⎣

⎡=

ddbbccaa

dbca

PandP00

11000110

;11000110

]det[

]det[

)(2)(2

)(21)(2

1))((

TsApA

T

bcadcacbdbbc

cdabdbcapA

=∴

=

−=++−++−

−−++=

(a+c, b+d)

(o,0)

(a,b)

(c,d)

Area Scaling exampleA triangle with vertices (1,0), (0,1) and (-1,0) is

transformed by

AreaVertices after transformation are

Transformed area,

unitssq.1)1)(2(21 ==iA

⎥⎦

⎤⎢⎣

⎡−

=2123

][T

⎥⎥⎥

⎢⎢⎢

−−−=⎥

⎤⎢⎣

⎡−

⎥⎥⎥

⎢⎢⎢

−=

232123

2123

011001

]'[X

unitssq.8)4)(4(21 == it AA

Page 16: 2D TRANSFORMATIONS (Contd.)

16

Geometrical Interpretation of Overall Scaling

h=1

h<1

h>1

[ ] [ ] [ ]

⎥⎦⎤

⎢⎣⎡

=⎥⎥⎥

⎢⎢⎢

⎡=

= 1

00010001

1**

sy

sx

syxs

yxhyx

Viewing Transformations• It is a transformation from world CS to Screen CS. The

dimensions of the WCS may be in any chosen system of units SI or FPS etc the latter is measured in pixels.

1. Translate the MCS base point to origin2. Apply the scaling necessary to fit into the screen limits (xmin,ymin

and xmax ymax)3. Move the base point back to its original position

[ ] [ ][ ][ ] 1−= tt TSTT

[ ]

1210001

100

00

00

1010001

minminminmax

minmaxminmax

minmax

minmin

⎥⎦

⎤⎢⎣

⎥⎥⎥

⎢⎢⎢

⎥⎦

⎤⎢⎣

⎡−−

−−

−−=

vuyyvv

xxuu

yxT

Page 17: 2D TRANSFORMATIONS (Contd.)

17

Translation

• What are invariant?– Lengths– Angles

• Which transformation group?– Congruent

• det[T]=1

Translation + Dilation

• What are invariant?– Ratio of Lengths– Angles

• Which transformation group?– similarity

• det[T]=1

Page 18: 2D TRANSFORMATIONS (Contd.)

18

Translation + Rotation

• What are the invariants?• Lengths• Angles• Which transformation

group?• Congruent• det[T]=1

Reflection

• What are the invariants?• Lengths• Angles• Which transformation

group?• Congruent• det[T] = -1

Page 19: 2D TRANSFORMATIONS (Contd.)

19

Reflection+Translation=Glide

• What are the invariants?• Lengths• Angles• Which transformation

group?• Congruent• det[T] = -1• Glide= Rm+Ta=Ta+Rm

m

a

a

Shear Transformation

4

2

-2

-4

6

5 10

• What are invariant?• parallelism

• Which transformation group?

• affine

Page 20: 2D TRANSFORMATIONS (Contd.)

20

Projective Transformation

• What are invariant?• Incidence• Cross ratios of

lengths• Order of curves

4

2

-2

-4

5 10

Isometries of a Square

• How many isometries?• identity• Rotational• Reflection

i 90 180 270

h v D1 D2

i18090270HD1VD2D2

180i27090VD2HD1D1

27090i180D2HD1VV

90270180iD1VD2HH

VHD1D218090i270270

D1D2hV90i270180180

HVD2D1i2701809090

D2D1VH27018090iI

D2D1VH27018090i

Cayle Table of isometries of a square

Page 21: 2D TRANSFORMATIONS (Contd.)

21

Transformations Possible in different Geometries

Central Projection

Shear

Non-uniform Scaling

Uniform Scaling

Translation

Rotation

ProjectiveAffineSimilarityEuclidianTransformation / Geometries

Invariant Quantities in different Geometries

Cross-ratios of Lengths

Incidence

Parallelism

Ratios of Lengths

Angles

Lengths

ProjectiveAffineSimilarityEuclidianTransformation / Geometries