cg - lecture 11
Post on 06-Apr-2018
223 Views
Preview:
TRANSCRIPT
-
8/3/2019 CG - Lecture 11
1/15
Lecture 9
2D Transformations IIBasic Transformations
-
8/3/2019 CG - Lecture 11
2/15
Basic Transformations:
Translation
Rotation
Scaling
-
8/3/2019 CG - Lecture 11
3/15
Translation:
Moving an point from one location to another location without altering
the point in a straight line is called translation
Translation is the displacement of the point along a straight line We translate a 2D point (x, y) by adding translation distances tx, ty, i.e.,
x = x + tx
y = y + ty
Where tx is the displacement in x direction and ty is the displacement in y
direction
The translation distance pair (tx, ty) is called the translation vector or shift
vector
-
8/3/2019 CG - Lecture 11
4/15
Translation:
We can use the matrices for the translated equations like:
Or we can write
xPy
!
txTty
!
''
'xPy
!
' P P T !
-
8/3/2019 CG - Lecture 11
5/15
Translation:
Translating an object
means moving an object
without deforming theobject i.e., every point of
the object is translated by
the same amount
-
8/3/2019 CG - Lecture 11
6/15
Translation:
-
1
3
-
5
5
tx = 2
ty = 4
-
8/3/2019 CG - Lecture 11
7/15
Rotation:
A rotation is applied to an object by reposition it along a circular path in
the xy plane
To generate a rotation we specify
The rotation angle and
The rotation point or the pivot point about which the object is to be rotated
If the angle is taken positive, the object is rotated counter clockwise If the angle is taken negative, the object is rotated clockwise
-
8/3/2019 CG - Lecture 11
8/15
Rotation:
Suppose the Point P = (x, y) is
the pivot point
Suppose the point is r unitsfrom the origin and making an
angle , then the parametric
equation for the P is
x = r cos
y = r sin
Now if we want to rotate this point
by degree, then
-
8/3/2019 CG - Lecture 11
9/15
Rotation:
The new angle will be ( + )
And the new point will be given by
x = r cos ( + ) = r cos cos r sin sin
y = r sin ( + ) = r cos sin + r sin cos
But we know that:
r cos = x and r sin = y
x = x cos y sin and
y = x sin + y cos
-
8/3/2019 CG - Lecture 11
10/15
Rotation:
In the matrix format, we get
i.e., P = R . P
'''
xPy
!
cos sinsin cos
R U U
U U
!
xPy
!
-
8/3/2019 CG - Lecture 11
11/15
Scaling:
A scaling transformation alters
the size of the object
It could be increasing the sizeof the object
Or decreasing the size of the
object
-1
2
6
3
-
Sx = 3
Sy= 3
-
8/3/2019 CG - Lecture 11
12/15
Scaling:
Suppose P = (x, y) is the point
and Sx is the scaling factor
along x-axis and Sy along y-axis,then the scaled point can be
expressed as
x = x . Sx
Y = y . Sy
To scale a polygon, we
calculated the scaled points for
each of the vertices
-1
2
6
3
-
Sx = 3
Sy= 3
-
8/3/2019 CG - Lecture 11
13/15
Scaling:
In the matrix format, we get
i.e., P = S . P
If the scaling factor is < 1, the size of the object will decrease
If the scaling factor is > 1, the size will increase
''
'xPy
!
0
0
SxS
Sy !
xPy
!
-
8/3/2019 CG - Lecture 11
14/15
Scaling:
There are two types of scaling
Uniform Scaling
Differential Scaling
In uniform scaling, the Sx and Sy values are always equal. By scaling an
object uniformly, the shape of the object remains intact
In differential scaling the Sx and Sy factors are unequal. By applying the
differential scaling, the object loses its original shape
-
8/3/2019 CG - Lecture 11
15/15
Scaling:
The scaling can be applied to lines, circles, polygons and ellipses
For a line, the scaling is applied at end points
For polygons, the scaling is applied at each vertex For circles and ellipses, the scaling is applied to only radii
top related