+ All Categories
Home > Documents > 2D Translation

2D Translation

Date post: 26-Jan-2016
Category:
Upload: ronat
View: 53 times
Download: 0 times
Share this document with a friend
Description:
6. 5. 4. Y. 3. 2. 1. dx = 2 dy = 3. 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. X. 2D Translation. Note: House shifts position relative to origin. A translation is applied to an object by repositioning - PowerPoint PPT Presentation
Popular Tags:
21
dx = 2 dy = 3 Y X 0 1 1 2 2 3 4 5 6 7 8 9 10 3 4 5 6 1 2 4 4 2D Translation A translation is applied to an object by repositioning it along a straight-line path from one coordinate location to another Component-wise addition of vectors v= v + t where and x’ = x + dx y’ = y + dy To move polygons: translate vertices (vectors) and redraw lines between them Preserves lengths (isometric) Preserves angles (conformal) www.Bookspar.com | Website for Students | VTU - Notes - Question Papers dy dx t y x v y x v , ' ' ' , Note: House shifts position relative to origin
Transcript
Page 1: 2D Translation

dx = 2dy = 3

Y

X 0

1

1

2

2

3 4 5 6 7 8 9 10

3

4

5

6

1

2

4

4

2D Translation

• A translation is applied to an object by repositioning it along a straight-line path from one coordinate location to another• Component-wise addition of vectors

v’ = v + t where

and x’ = x + dx y’ = y + dy

To move polygons: translate vertices (vectors) and redraw lines between them

• Preserves lengths (isometric)• Preserves angles (conformal)

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

dy

dxt

y

xv

y

xv ,

'

'',

Note: House shifts position relative to origin

Page 2: 2D Translation

2D Translation• Rigid body transformation• Polygons are translated by adding the translation vector

to the coordinate position of each vertex and generating the polygon using the new set of vertex coordinates

• For circle and ellipse, translate the center coordinates and redraw the object in the new location

• Translate the curves by (say, splines) displacing the coordinate positions defining the objects and redraw using translated points

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

Page 3: 2D Translation

2D Scaling

• The scaling alters the size of an object • Component-wise scalar multiplication of vectors

v’ = Sv where

and

• Does not preserve lengths• Does not preserve angles (except when scaling is uniform)

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

'

'',

y

xv

y

xv

y

x

s

sS

0

0

ysy

xsx

y

x

'

'

Y

X 0

1

1

2

2

3 4 5 6 7 8 9 10

3

4

5

6

1

2

1

3

2

6

2

9

2

3

y

x

s

s

Note: House shifts position relative to origin

)1(.)('

)1(.)('

yfyyff

xfxxff

sysysyyyy

sxsxsxxxx

Page 4: 2D Translation

2D Rotation

• A 2D rotation is applied to an object by repositioning it along a circular path in the xy-plane

• Rotation of vectors through an angle θ

v’ = Rθ v where

and x’ = x cos θ – y sin θ y’ = x sin θ + y cos θ

• Proof by double angle formula• Preserves lengths and angles

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

cossin

sincosR

'

'',

y

xv

y

xv

6

Y

X 0

1

1

2

2

3 4 5 6 7 8 9 10

3

4

5

6

NB: A rotation by 0 angle, i.e. no rotation at all, gives us the identity matrix

Note: House shifts position relative to origin

x = r cos (y = r sin (x = r cos

y = r sin

Page 5: 2D Translation

Rotation about fixed points

cos)(sin)('

sin)(cos)('

rrr

rrr

yyxxyy

yyxxxx

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

6

Y

X 0

1

1

2

2

3 4 5 6 7 8 9 10

3

4

5

6

Page 6: 2D Translation

2D Rotation• Rigid body transformation• Every point on the object is rotated with the same

angle• Straight line segment is rotated by applying the

rotation equations to line end points and redrawing with new end points

• Polygons are rotated by displacing each vertex through the specified rotation angle and regenerating the polygon using new vertices

• Curved lines are rotated by repositioning the defining points and redrawing the curves

• Circle can be rotated about a non central axis by moving the center position through the arc that subtends the specified rotation angle

• Ellipse can be rotated about its center coordinates by rotating the major and minor axes

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

Page 7: 2D Translation

2D Rotation and Scale are Relative to Origin

• Suppose object is not centered at origin• Solution: move to the origin, scale and/or rotate,

then move it back.

• Would like to compose successive transformations…

Page 8: 2D Translation

Reflection

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

• Reflection produces a mirror image of an

object

• Mirror image for a 2D reflection is generated relative to an axis of reflection by rotating the object 180 degrees

• corresponds to negative scale

factors

originalsx = -1 sy = 1

sx = -1 sy = -1 sx = 1 sy = -1

Page 9: 2D Translation

Shear

1000

0100

0010

00cot 1

• Shear distorts the shape

• Helpful to add one more basic transformation

• Equivalent to pulling faces in opposite directions

Consider simple shear along x axis

x’ = x + y cot y’ = yz’ = z

H() =

Page 10: 2D Translation

Homogenous Coordinates• Translation, scaling and rotation are expressed (non-

homogeneously) as:

• Composition is difficult to express– Translation is not expressed as a matrix multiplication

• Homogeneous coordinates allows expression of all three as 3x3 matrices for easy composition

• w is 1 for affine transformations

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

translation:

scale:

rotation:

v’ = v + t

v’ = Sv

v’ = Rv

w

y

w

xPyxP

wwyxP

wwwywxPyxP

dd

h

hd

',

'),(

0),,','(

0),,,(),(

22

2

Page 11: 2D Translation

What is ?• P2d is intersection of line determined by Ph with the

w = 1 plane

• Infinite number of points correspond to (x, y, 1) : they constitute the whole line (tx, ty, tw)

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

w

y

x

P2d (x/w,y/w,1)

Ph (x,y,w)

Y

X

W

1

Page 12: 2D Translation

2D Homogeneous CoordinateTransformations

• For points written in homogeneous coordinates,

translation, scaling and rotation relative to the origin are

expressed homogeneously as:

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

1

y

x

v

1

'

'

' y

x

v

Page 13: 2D Translation

2D Homogeneous Coordinate Transformations

• Consider the rotation matrix:

• The 2 x 2 submatrix columns are:– unit vectors (length=1)– perpendicular (dot product=0)– vectors into which X-axis and Y-axis rotate (are

images of x and y unit vectors)• The 2 x 2 submatrix rows are:

– unit vectors– perpendicular– rotate into X-axis and Y-axis (are pre-images of x

and y unit vectors)• Preserves lengths and angles of original geometry.

Therefore, matrix is a “rigid body” transformation

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

Page 14: 2D Translation

Examples• Translate [1,3] by [7,9]

• Scale [2,3] by 5 in the x direction and 10 in the Y direction

• Rotate [2,2] by 90°

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

Page 15: 2D Translation

Matrix Compositions: Using Translation

• Avoiding unwanted translation when scaling or rotating an object not centered at origin: – translate object to origin, perform scale or rotate,

translate back.

• How would you scale the house by 2 in “its” y and rotate it through 90° ?

• Remember: matrix multiplication is not commutative! Hence order matters

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

HdydxTRdydxTHdydxTRHdydxTHHouse ),()(),(),()(),()(

HSRH,SHHouse )2,1()2/()21()(

Page 16: 2D Translation

Y

X 0

1

1

2

2

3 4 5 6 7 8 9 10

3

4

5

6

Y

X 0

1

1

2

2

3 4 5 6 7 8 9 10

3

4

5

6

Translation → Rotation

Rotation → Translation

Transformations are NOT Commutative

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

Page 17: 2D Translation

3D Basic Transformations

• Translation

• Scaling

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

(right-handed coordinate system)

1000

100

010

001

dz

dy

dx

1000

000

000

000

z

y

x

s

s

s

x

y

z

Page 18: 2D Translation

3D Basic Transformations

• Rotation about X-axis

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

(right-handed coordinate system)

1000

0cossin0

0sincos0

0001

1000

0cos0sin

0010

0sin0cos

1000

0100

00cossin

00sincos

• Rotation about Y-axis

• Rotation about Z-axis

For rotation about x axis, x is unchanged

For rotation about y axis, y is unchanged

• Rotation about z axis in three dimensions leaves all points with the same z• Equivalent to rotation in two dimensions in planes of constant z

Page 19: 2D Translation

Inverses of (2D and) 3D Transformations

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

1. Translation:

2. Scaling:

3. Rotation:

4. Shear:

),,(),,(1zyxzyx dddTdddT

)1

,1

,1

(),,(1

zyxzyx sss

SsssS

)()()(1 TRRR

),(),(1yxyx shshSHshshSH

Page 20: 2D Translation

References

• Edward Angel –Interactive Computer Graphics

• Hearn and Baker - Computer Graphics

• James D. Foley - Computer Graphics: principles and practice

• Asthana and Sinha- Computer Graphics

• PPTs: Von Dom, Bing-Yu Chen

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers

Page 21: 2D Translation

THANK YOU

www.Bookspar.com | Website for Students | VTU - Notes -

Question Papers


Recommended