Presentation is loading. Please wait.

Presentation is loading. Please wait.

Gopi -ICS280F02 - Slide 1 Model Transformations. Gopi -ICS280F02 - Slide 2 Popular Linear Transformations TranslationTranslation ScalingScaling RotationRotation.

Similar presentations


Presentation on theme: "Gopi -ICS280F02 - Slide 1 Model Transformations. Gopi -ICS280F02 - Slide 2 Popular Linear Transformations TranslationTranslation ScalingScaling RotationRotation."— Presentation transcript:

1 Gopi -ICS280F02 - Slide 1 Model Transformations

2 Gopi -ICS280F02 - Slide 2 Popular Linear Transformations TranslationTranslation ScalingScaling RotationRotation ShearShear

3 Gopi -ICS280F02 - Slide 3 Translation Translation is displacement of a point by a vector.Translation is displacement of a point by a vector. Translation of an object is achieved by displacing every point belonging to that object by the same vector.Translation of an object is achieved by displacing every point belonging to that object by the same vector. A vector cannot be “translated”.A vector cannot be “translated”. Point P: (x,y,z) Vector V:(tx,ty,tz) then Translated Point TP:(x+tx, y+ty, z+tz)Point P: (x,y,z) Vector V:(tx,ty,tz) then Translated Point TP:(x+tx, y+ty, z+tz)

4 Gopi -ICS280F02 - Slide 4 Using matrix for translation Point P: (x,y,z,1) (Homogeneous representation)Point P: (x,y,z,1) (Homogeneous representation) Translation Vector V: (tx,ty,tz)Translation Vector V: (tx,ty,tz) 100tx 010ty 001tz 0001xy z 1 =x+txy+ty z+tz 1

5 Gopi -ICS280F02 - Slide 5 Example translation

6 Gopi -ICS280F02 - Slide 6 Rotation Rotation (in 3D) requires an axis and an angle (r).Rotation (in 3D) requires an axis and an angle (r). The equation changes with the coordinate system (right handed or left handed system)The equation changes with the coordinate system (right handed or left handed system) In graphics, assume right handed system unless otherwise specified. (OpenGL uses right handed system.)In graphics, assume right handed system unless otherwise specified. (OpenGL uses right handed system.)

7 Gopi -ICS280F02 - Slide 7 Matrix for Rotation about Z r (x,y) (x’,y’) cos(r) -sin(r) 00 sin(r) cos(r) 00 0010 0001 xy z 1 =x’y’ z’ 1 X Y Z axis is pointing out of the screen)

8 Gopi -ICS280F02 - Slide 8 Matrix for Rotation about X and Y cos(r) 0 sin(r) 0 0100 -sin(r) 0 cos(r) 0 0001 xy z 1 =x’y’ z’ 1 10000 -sin(r) 0 0 sin(r) cos(r) 0 0001 xy z 1 =x’y’ z’ 1

9 Gopi -ICS280F02 - Slide 9 Matrix for Scaling (x,y) (s x x,s y y) sxsxsxsx000 0 sysysysy00 00 szszszsz0 0001xy z 1 = sxxsxxsxxsxx syysyysyysyy szzszzszzszz 1 X Y Z axis is pointing out of the screen) =x’y’ z’ 1

10 Gopi -ICS280F02 - Slide 10 Shear Translation of one coordinate of a point is proportional to the ‘value’ of the other coordinate of the same point.Translation of one coordinate of a point is proportional to the ‘value’ of the other coordinate of the same point. –Point : (x,y) –After ‘y-shear’: (x+ay,y) –After ‘x-shear’: (x,y+bx) Changes the shape of the object.Changes the shape of the object.

11 Gopi -ICS280F02 - Slide 11 Using matrix for Shear Example: Z-shear (Z coordinate does not change)Example: Z-shear (Z coordinate does not change) 10a0 01b0 0010 0001xy z 1 =x+azy+bz z 1 =x’y’ z’ 1

12 Gopi -ICS280F02 - Slide 12 Composition of Transformations Example: A point P is first translated and then rotated. Translation matrix T, Rotation Matrix R.Example: A point P is first translated and then rotated. Translation matrix T, Rotation Matrix R. –After Translation: P’= TP –After Rotation: P’’=RP’=RTP Example: A point is first rotated and then translated.Example: A point is first rotated and then translated. –After Rotation: P’= RP –After Translation: P’’=TP’=TRP Since matrix multiplication is not commutative,Since matrix multiplication is not commutative, –RTP = TRP

13 Gopi -ICS280F02 - Slide 13 Composition of Transformations X Y X Y X Y T R X Y X Y X Y T R TRP RTP

14 Gopi -ICS280F02 - Slide 14 Coordinate Systems You Say: A point P is “first translated” and “then rotated”.You Say: A point P is “first translated” and “then rotated”. You Write: P’ = RTP (write Rotation first, then translation, then the point)You Write: P’ = RTP (write Rotation first, then translation, then the point) Say: “Global Coordinate System”Say: “Global Coordinate System” Write: “Local Coordinate System”Write: “Local Coordinate System” Results of both are same. Interpretation is different.Results of both are same. Interpretation is different.

15 Gopi -ICS280F02 - Slide 15 Local / Global Coordinate Systems X Y X Y X Y X Y X Y X Y “Local” Y “Local” X “Local” Y “Local” X GCS: You say “point is first translated and then rotated” LCS: You say as you write: “RTP”

16 Gopi -ICS280F02 - Slide 16 Coordinate Systems OpenGL follows LOCAL COORDINATE SYSTEM glTranslate(…)glRotate(…)glScale(…)DrawModel() Means: TRS.P (You issue transformation commands in the order your write!!)

17 Gopi -ICS280F02 - Slide 17 End


Download ppt "Gopi -ICS280F02 - Slide 1 Model Transformations. Gopi -ICS280F02 - Slide 2 Popular Linear Transformations TranslationTranslation ScalingScaling RotationRotation."

Similar presentations


Ads by Google