Chapter3-Two Dimensional Transformations
Chapter3-Two Dimensional Transformations
Two Dimensional
Transformations
Basic Transformation
• Design applications and facility layouts are created by
arranging the orientations and sizes of the component parts
of the scene.
• And animations are produced by moving the "camera" or
the objects in a scene along animation paths.
• Changes in orientation, size, and shape are accomplished
with geometric transformations that alter the coordinate
descriptions of objects.
• The basic geometric transformations are translation,
rotation, and scaling.
• Other transformations that are often applied to objects
include reflection and shear.
Translation
• A translation is applied to an object by
repositioning it along a straight-line path from
one coordinate location to another.
• We translate a two-dimensional point by adding
translation distances, tx and ty to the original
coordinate position (x, y) to move the point to a
new position ( x', y').
x'= x + tx y' = y + ty
• The translation distance pair (tx, ty) is called a
translation vector or shift vector.
• We can express the translation equations as a
single matrix equation by using column vectors
to represent coordinate positions and the
translation vector.
𝒙 𝒙′ 𝒕𝒙
P= 𝒚 P’= T= 𝒕𝒚
𝒚′
• This allows us to write the
two-dimensional translation
equations in the matrix form:
P' =P+T
• Sometimes matrix-transformation equations are expressed
in terms of coordinate row vectors instead of column
vectors.
• We would write the matrix representations as
P = [x y] & T=[tx ty]
• The graphics packages GKS and PHIGS, also use the
column-vector representation.
• Translation is a rigid-body transformation that moves
objects without deformation.
• That is, every point on the object is translated by the same
amount.
• A straight Line segment is translated by applying the
transformation equation to each of the line endpoints and
redrawing the line between the new endpoint positions.
• Figure shows the
application of a specified
translation vector to move
an object from one position
to another.
• Similar methods are used
to translate curved objects.
• To change the position of a
circle or ellipse, we
translate the centre
coordinates and redraw the
figure in the new location.
Rotation
• A two-dimensional rotation is applied to an object by
repositioning it along a circular path in the xy plane.
• To generate a rotation, we specify a rotation angle θ
and the position (xr, yr) of the rotation point (or pivot
point) about which the object is to be rotated.
• Positive values for the rotation angle define counter
anti clockwise rotations about the pivot point,
• Negative values rotate objects in the clockwise
direction.
• This transformation can also be described as a
rotation about the rotation axis that is perpendicular
to the xy plane.
θ
Φ
• In the figure,
• r is the constant distance of the point from the
origin,
• angle Φ is the original angular position of the
point from the horizontal, &
• θ is the rotation angle.
• We can express the coordinates as:
x2 = r cos(Φ+θ) = r cosΦ cosθ – r sinΦ sinθ
y2 = r sin(Φ+θ) = r cosΦ sinθ + r sinΦ cosθ
• The original coordinates of the points in the
polar coordinates are
x = r cosΦ , y = r sinΦ
• We obtain the transformation equations for
rotating a point (x,y) through an angle θ about
the origin is:
x' = x cos θ – y sin θ
y' = x sin θ + y cos θ
• We can write the rotation equations in the
matrix form
P'=R.P
• where the rotation matrix is
cosθ −sinθ
R=
sinθ cosθ
• When coordinate positions are represented as row vectors
instead of column vectors, the matrix product in rotation
equation is transposed so that the transformed row
coordinate vector [x' y'] is calculated as
𝑷′𝑻 = (𝑹. 𝑷)𝑻
= 𝑷𝑻 . 𝑹𝑻
• where 𝑷𝑻 = [x y], and the transpose 𝑹𝑻 of matrix R is
obtained by interchanging rows and columns.
• For a rotation matrix, the transpose is obtained by simply
changing the sign of the sine terms.
• As with translations, rotations are rigid-body
transformations that move objects without deformation.
• Every point on an object is rotated through the same angle.
• A straight line segment is rotated by applying the rotation
equations to each of the line endpoints and redrawing the
line between the new endpoint positions.
• Polygons are rotated by displacing each vertex through the
specified rotation angle and regenerating the polygon using
the new vertices.
• Curved lines arc rotated by repositioning the defining points
and redrawing the curves.
• A circle or an ellipse, for instance, can be rotated about a
noncentral axis by moving the center position through the
arc that subtends the specified rotation angle.
• An ellipse can be rotated about its center coordinates by
rotating the major and minor axes.
Scaling
• A scaling transformation alters the size of an object.
• This operation can be carried out for polygons by
multiplying the coordinate values (x, y) of each vertex by
scaling factors Sx and Sy to produce the transformed
coordinates (x', y')
X'=X.Sx Y'=Y.Sy
• Scaling factor Sx scales objects in the x direction, while Sy
scales in the y direction.
• The transformation equations can also be written in the
matrix form:
𝒙′ 𝑺𝒙 𝟎 𝒙
= . 𝒚
𝒚′ 𝟎 𝑺𝒚
• There are three scaling factors:
(i) A scaling constant > 1 indicates
expansion of length ie. Magnification
(ii) A scaling constant < 1 indicates
compression of length ie. reduction
(iii) A scaling constant = 1 leaves the size of
object unchanged.
• When assigned the same value, a uniform
scaling is produced & for unequal values
Sx and Sy differential scaling is produced.
• Objects transformed with equation are
both scaled and repositioned.
• Scaling factors with values less than 1
move objects closer to the coordinate
origin, while values greater than 1
move coordinate positions farther
from the origin.
• Figure shows scaling a line by
assigning the value 0.5 to both Sx and
Sy in equation.
• Both the line length and the distance
from the origin are reduced by a factor
of 1 /2.
• Coordinates for the fixed point (Xf, Yf) can be chosen as one of
the vertices, the object centroid, or any other position
• A polygon is then scaled relative to the fixed point by scaling
the distance from each vertex to the fixed point.
• For a vertex with coordinates (x, y), the scaled coordinates
(x',y') are calculated as
X'=Xf +(X - Xf) Sx, Y'=Yf +(Y - Yf) Sy
• We can rewrite these scaling transformations to
separate. the multiplicative and additive terms:
X‘=X.Sx + Xf(1-Sx)
Y‘=Y.Sy + Yf(1-Sy)
• where the additive terms Xf,(1 - Sx) and Yf(1 - Sy)
are constant for all points in the object.
• Polygons are scaled by applying transformations , to each
vertex and then regenerating the polygon using the
transformed vertices.
• Other objects are scaled by applying the scaling
transformation equations to the parameters defining the
objects.
• An ellipse in standard position is resized by scaling the
semimajor and semiminor axes and redrawing the ellipse
about the designated center coordinates.
• Uniform scaling of a circle is done by simply adjusting the
radius.
• Then we redisplav the circle about the center coordinates
using the transformed radius.
MATRlX RFPRESENTATlONS &
HOMOGENEOUS COORDINATES
• We perform translations, rotations, and scaling to fit the picture
components into their proper positions.
• The basic transformations can be expressed in the general
matrix form
P' = M1 . P +M2
• with coordinate positions P and P' represented as column
vectors.
• Matrix M1 is a 2 by 2 array containing multiplicative factors,
and m2 is a two-element column matrix containing
translational terms.
• For translation, M2 is the identity matrix.
• For rotation or scaling, M1 contains the translational terms
associated with the pivot point or scaling fixed point.
• To produce a sequence of transformations with these
equations, such as scaling followed by rotation then
translation, we must calculate the transformed coordinates
one step at a time.
• First, coordinate positions are scaled,
• Then these scaled coordinates are rotated, and
• Finally the rotated coordinates are translated.
• A more efficient approach would be to combine the
transformations so that the final coordinate positions are
obtained directly from the initial coordinates,
• thereby eliminating the calculation of intermediate
coordinate values.
• To he able to do this, we need to reformulate above equation
to eliminate the matrix addition associated with the
translation terms in M2.
• We can combine the multiplicative and
translational terms for 2D geometric
transformations into a single matrix
representation
• by expanding the 2 by 2 matrix
representations to 3 by 3 matrices.
• This allows us to express all transformation
equations as matrix multiplications,
providing that we also expand the matrix
representations for coordinate positions.
• To express any two-dimensional transformation
as a matrix multiplication, we represent each
Cartesian coordinate position ( x, y) with the
homogeneous coordinate triple (Xh, Yh, h)
where,
𝑿𝒉 𝒀𝒉
x= y=
𝒉 𝒉
• Equations containing x and y, such as f(x, y) = 0,
become homogeneous equation in the three
parameters 𝑋ℎ, 𝑌ℎ, h where we set h=1.
• Expressing positions in homogeneous
coordinates allows us to represent all geometric
transformation équations as matrix
multiplications.
Translation:
• Coordinates are represented with three-element column
vectors, and transformation operations are written as 3 bv
3 matrices. For translation. we have