chapter5 transformations
Post on 18-Oct-2015
68 Views
Preview:
DESCRIPTION
TRANSCRIPT
-
Computer GraphicsChapter 5Geometric TransformationsAndreas Savva
-
2D 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 + tyMatrix form
-
2D TranslationMoving a polygon from position (a) to position (b) with the translation vector (-5, 10), i.e.(a)(b)
-
Translating a Polygonclass Point2D { public: GLfloat x, y;};
void translatePoly(Point2D P[], GLint n, GLfloat tx, GLfloat ty){GLint i;for (i=0; i
-
2D RotationRepositioning an object along a circular path in the xy-planeThe original coordinates are:
-
2D RotationSubstitutingMatrix form
-
2D Rotation about a Pivot positionRotating about pivot position (xr, yr)
- Translating a Polygonclass Point2D { public: GLfloat x, y;};void rotatePoly(Point2D P[], GLint n, Point2D pivot, GLdouble theta){ Point2D *V; V = new Point2D[n]; GLint i; for (i=0; i
-
2D ScalingAltering the size of an object. Sx and Sy are the scaling factors. If Sx = Sy then uniform scaling.Matrix form
-
2D Scaling relative to Fixed pointScaling relative to fixed point (xf, yf)ORwhere the additive terms xf(1-Sx) and yf(1-Sy) areconstants for all points in the object.
- Translating a Polygonclass Point2D { public: GLfloat x, y;};void scalePoly(Point2D P[], GLint n, Point2D fixedPt, GLfloat Sx, GLfloat Sy){ Point2D *V; V = new Point2D[n]; GLfloat addx = fixedPt.x * (1 Sx); GLfloat addy = fixedPt.y * (1 Sy); GLint i; for (i=0; i
-
Matrix RepresentationUse 33 matrices to combine transformations
Translation
Rotation
Scaling
-
Inverse TransformationsTranslation
Rotation
Scaling
-
ExampleConsider the line with endpoints (10, 10) and (30, 25). Translate it by tx = -20, ty = -10 and then rotate it by = 90.Right-to-left
-
Solution
-
Solution (continue)Point (10, 10)Point (30, 25)
-
ResultStep-by-stepT(-20, -10)R(90)
-
ExercisesConsider 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.
-
ExercisesComposite 2D TransformationsTranslation: Show that:
Rotation: Show that:
Scaling: Show that:
-
General 2D Pivot-Point RotationOriginal positionand Pivot PointTranslate Object so thatPivot Point is at originRotation about originTranslate object so that Pivot Pointis return to position (xr , yr)
-
General Pivot-point RotationUsing Matrices
-
ExercisesConsider 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.
-
General 2D Fixed-Point ScalingOriginal positionand Fixed PointTranslate Object so thatFixed Point is at originScale Object withrespect to originTranslate Object so that Fixed Pointis return to position (xf , yf)
-
General 2D Fixed-Point ScalingUsing Matrices
-
ExercisesConsider 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.
-
Order of Transformations
-
ReflectionAbout the x axisAbout the y axis
-
ReflectionRelative to the coordinate originWith respect to the line y = x
-
2D Shearx-direction shearMatrix form
-
2D Shearx-direction relative to other reference lineMatrix formy
-
2D Sheary-direction shearMatrix form
-
2D Sheary-direction relative to other reference lineMatrix formshy = , xref = -1
-
Transformations between 2D Coordinate SystemsTo translate object descriptions from xy coordinates to xy coordinates, we set up a transformation that superimposes the xy axes onto the xy axes. This is done in two steps:Translate so that the origin (x0, y0) of the xy system is moved to the origin (0, 0) of the xy system.Rotate the x axis onto the x axis.
-
Transformations between 2DCoordinate Systemsi.e.1)
2)
Concatenating:
-
ExampleFind the xy-coordinates of the xy points (10, 20) and (35, 20), as shown in the figure below:
-
ExerciseFind the xy-coordinates of the rectangle shown in the figure below:
-
3D TranslationRepositioning an object along a straight line path from one co-ordinate location to another(x,y,z) (x,y,z) To translate a 3D position, we add translation distances tx ty and tz to the original coordinates (x,y,z) to obtain the new coordinate position (x,y)x= x + tx , y= y + ty , z= z + tz
Matrix form (4 4)
-
3D Rotationz-axisThe 2D z-axis rotation equations are extended to 3D.Matrix form
-
3D Rotationx-axisMatrix form
-
3D Rotationy-axisMatrix form
-
3D ScalingMatrix form
-
Other 3D TransformationsReflection z-axisShears z-axis
top related