part7: geometric transformations. transformation means changes in orientation, size, and shape. ...

26
Computer Graphics Part7 : Geometric Transformations

Upload: audrey-farmer

Post on 30-Dec-2015

246 views

Category:

Documents


2 download

TRANSCRIPT

Computer Graphics

Computer GraphicsPart7: Geometric Transformations12D TransformationsTransformation means changes in orientation, size, and shape.

The basic geometric transformations are translation, rotation, and scaling. Other transformations that are often applied to objects include reflection and shear ( ). 2April 8, 20142Transformations Translationmoving thingsRotationmoving about a pointby a given anglerotation point may be originor some other chosen pointScalingchanging sizerelative to originor some other chosen point

3April 8, 201432D TranslationRepositioning 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 + ty4TxyMatrix form

42D TRANSLATIONExample: Let P = (5, 9), T = (tx, ty) = ( 6, 8) , so P' = (11, 17)

Note: To translate a line translate its endpoints. To translate polygon ( ) translate its vertices. Circle or Ellipse: Translate boundary points.5April 8, 201452D TranslationMoving a polygon from position (a) to position (b) with the translation vector (-5, 10), i.e.6xy51015205101520(a)xy51015205101520(b)

62D TRANSLATION We think of a point as a column vector, written as a column of numbers between parentheses.

We add vectors by adding corresponding coordinates.7

April 8, 201472D RotationRepositioning an object along a circular path in the xy-plane8

xy(x,y)(x,y)rrThe original coordinates are:

82D RotationSubstituting9Matrix form

xy(x,y)(x,y)rr92D Rotation Example10Rotate the line endpoints (1,2) and ( 4,3) about origin by 90 degree.p(1,2) >>>>> p(-2,1) x=1*cos 90 2*sin 90 = -2 y=1*sin 90 + 2*cos 90= 1

P(4,3) >>>>>>> p(-3,4)x=4*cos 90 3*sin 90= -3y=4*sin 90 + 3*cos 90= 4

Cos 90 = 0Sin 90 = 1102D Rotation about a Pivot positionRotating about pivot position (xr, yr)11

xy(x,y)(x,y)rrxryr11Example12Rotate the line endpoints (2,1) about point (3,3) by 90

x=3+(2-3) cos 90 (1-3) sin 90x=32=5

y=3+(2-3) sin 90 + (3-1) cos 90 = 3-1=2

122D ScalingAltering the size of an object. Sx and Sy are the scaling factors. If Sx = Sy then uniform scaling.Sx and Sy can be any positive value. Values < 1 reduces the size of the object. Values > 1 produces and enlargement. If Sx and Sy is 1, then the size is unchanged.13

Matrix form

132D Scaling relative to Fixed pointScaling relative to fixed point (xf, yf)14

xySx = , Sy = P1P2P3P1P2P3(xf , yf)14Matrix RepresentationUse 33 matrices to combine transformations

Translation

Rotation

Scaling15

15Inverse TransformationsTranslation

Rotation

Scaling16

16ExampleConsider the line with endpoints (10, 10) and (30, 25). Translate it by tx = -20, ty = -10 and then rotate it by = 90.17xy(10, 10)(30, 25)17Result18xy(10, 10)(30, 25)(0, -10)(-15, 10)xy(10, 15)(-10, 0)xy(0, -10)(-15, 10)T(-20, -10)R(90)18ExercisesConsider the following object:

Apply a rotation by 145 then scale it by Sx=2 and Sy=1.5 and then translate it by tx=20 and ty=-30.Scale it by Sx= and Sy=2 and then rotate it by 30.Apply a rotation by 90 and then another rotation by 45.Apply a rotation by 135.19xy1010254519ExercisesConsider the following object:

Apply a rotation by 60 on the Pivot Point (-10, 10) and display it.Apply a rotation by 30 on the Pivot Point (45, 10) and display it.Apply a rotation by 270 on the Pivot Point (10, 0) and then translate it by tx = -20 and ty = 5. Display the final result.20xy1010254520ExercisesConsider the following object:

Scale it by sx = 2 and sy = relative to the fixed point (140, 125) and display it.Apply a rotation by 90 on the Pivot Point (50, 60) and then scale it by sx = sy = 2 relative to the Fixed Point (0, 200). Display the result.Scale it sx = sy = relative to the Fixed Point (50, 60) and then rotate it by 180 on the Pivot Point (50, 60). Display the final result.21xy6050125220213D Translation(x,y,z) (x,y,z)

x= x + tx , y= y + ty , z= z + tz

22Matrix form (4 4)

T(tx, ty, tz)xyz223D Rotationz-axis:23Matrix form

xyzxyz

233D Rotationx-axis:24Matrix form

xyz

243D Rotationy-axis:25Matrix form

xyz

253D Scaling26Matrix form

xyz26