0% found this document useful (0 votes)
84 views

Chapter3-Two Dimensional Transformations

This document discusses two-dimensional geometric transformations including translation, rotation, scaling, and their matrix representations. It explains how to apply translations by adding a translation vector to coordinate positions. Rotations are applied by multiplying coordinate positions by a rotation matrix. Scaling transforms sizes by multiplying coordinates by scaling factors. These basic transformations can be combined and expressed using homogeneous coordinates and 3x3 transformation matrices.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views

Chapter3-Two Dimensional Transformations

This document discusses two-dimensional geometric transformations including translation, rotation, scaling, and their matrix representations. It explains how to apply translations by adding a translation vector to coordinate positions. Rotations are applied by multiplying coordinate positions by a rotation matrix. Scaling transforms sizes by multiplying coordinates by scaling factors. These basic transformations can be combined and expressed using homogeneous coordinates and 3x3 transformation matrices.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Chapter 3

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

• which we can write in the abbreviated form

• The inverse of the translation matrix is obtained by


replacing the translation parameters tx, and ty, with their
negatives: -tx and -ty.
Rotation:
• Rotation transformation equations about the
coordinate origin are written as

• The rotation transformation operator R(θ) is the 3


by 3 matrix in equation with rotation parameter θ.
• We get the inverse rotation matrix when θ is
replaced with -θ.
Scaling:
• Scaling transformation relative to the coordinate
origin is now expressed as the matrix
multiplication.

• where S(Sx, Sy) is the 3 by 3 matrix in Equation


with parameters sx and sy.
• Replacing these parameters with their
multiplicative inverses (1/Sx and 1/Sy) yields the
inverse scaling matrix.
Composite Transformation
• The matrix representations can set up a matrix for
any sequence of transformations as a composite
transformation matrix by calculating the matrix
product of the individual transformations.
• Forming products of transformation matrices is
referred to as a concatenation, or composition,
of matrices.
• Each successive transformation matrix pre-
multiplies the product of the preceding
transformation matrices.
i) Translation:
• Two successive translation vectors (𝑡𝑥1, 𝑡𝑦1 ) and
(𝑡𝑥2, 𝑡y2) are applied to a co-ordinate position P,
the final transformed location P' is calculated as:

• Two successive translation operations are


additive.
ii) Rotation:
• Two successive rotation angle θ1 and θ2 are
applied to a co-ordinate point P produces the
transformation position P'.

• Two successive rotation operations are additive.


iii) Scaling:
• Concatenating transformation matrix for two
successive scaling produces the following
composite scaling matrix.

• Two successive scaling operations are


multiplicative.
General Pivot Point Rotation:
• A graphics package that provides a rotate function,
for rotating an object about the co-ordinate origin.
• We can generate rotations about any selected pivot
point (Xr, Yr) by performing the following
sequence of translate-rotate -translate operations:
1) Translate the object so that the pivot-point
position is moved to the coordinate origin.
2) Rotate the object about the coordinate origin.
3) Translate the object so that the pivot point is
returned to its original position (Inverse
translation).
Figure shows a Transformation sequence for rotating an
object at pivot point
• The composite transformation matrix for the sequence is
obtained with the concatenation.

which can be expressed in the form


General Fixed Point Scaling
• A transformation sequence to produce scaling with
respect to a selected fixed position (Xf, Yf) using a
scaling function that can only scale relative to the
coordinate origin.
• We perform the following sequence translate-
scaling-translate operations:
1) Translate object so that the fixed point coincides
with the coordinate origin.
2) Scale the object with respect to the coordinate
origin.
3) Translate the object so that the fixed point is
returned to its original position (Inverse
translation).
• Figure shows a Transformation sequence for
scaling object with respect to fixed point positions
(Xf, Yf):
• Concatenating the matrices for these three
operations produces the required scaling matrix
Reflection
• A reflection is a transformation that produces a mirror
image of an object.
• Since the reflection P’ of an object point P is located the
same distance from the mirror as P.
(i) The mirror reflection transformation Mx about the x-axis
is given by:
P’ = Mx (P)
• where, x’ = x & y’ = -y
• It can be represented in matrix form as:
𝒙 𝒙′ 𝟏 𝟎
P= 𝒚 P’= Mx=
𝒚′ 𝟎 −𝟏
(ii) The mirror reflection transformation My about y-axis is
given by: P’ = My(P)
• where, x’ = -x & y’ = y
• It can be represented in matrix form as:
𝒙 𝒙′ −𝟏 𝟎
P= 𝒚 P’= My=
𝒚′ 𝟎 𝟏
With Homogenous Coordinates,
• Reflection about the line y = 0, the
x axis, is accomplished with the
transformation matrix
𝟏 𝟎 𝟎
𝟎 −𝟏 𝟎
𝟎 𝟎 𝟏
• This transformation keeps x values
the same, but "flips" the y values of
coordinate positions.
• The resulting orientation of an
object after it has been reflected
about the x axis is shown in Fig
With Homogenous
Coordinates,
• Reflection about the line
x=0, the y axis, is
accomplished with the
transformation matrix
−𝟏 𝟎 𝟎
𝟎 𝟏 𝟎
𝟎 𝟎 𝟏
• A reflection about the y axis
flips x coordinates while
keeping y coordinates the
same.
• The resulting orientation of
an object after it has been
reflected about the y axis is
shown in Fig
• We flip both the x and y
coordinates of a point by
reflecting relative to an axis
that is perpendicular to the
xy plane and that passes
through the coordinate
origin.
• This transformation,
referred to as a reflection
relative to the coordinate
origin, has the matrix
representation:
−𝟏 𝟎 𝟎
𝟎 −𝟏 𝟎
𝟎 𝟎 𝟏
• Reflection can be generalized to any reflection
point in the xy plane.
• This reflection is the same as a 180" rotation in
the xy plane using the reflection point as the
pivot point.
• If we chose the
reflection axis as the
diagonal line y = x, the
reflection matrix is
𝟎 𝟏 𝟎
𝟏 𝟎 𝟎
𝟎 𝟎 𝟏
• We can derive this
matrix by concatenating
a sequence of rotation
and coordinate-axis
reflection matrices
Shear
• The shear transformation distorts an object by
scaling one coordinate using the other

Original Data Y Shear X Shear


• With An x-direction shear relative to the x axis is
produced with the transformation matrix
𝟏 𝑺𝒉𝒙 𝟎
𝟎 𝟏 𝟎
𝟎 𝟎 𝟏
• which transforms coordinate position as
x’ = x + Shx .y & y’ = y
• We can generate x-direction shears relative to
other reference lines with
𝟏 𝑺𝒉𝒙 − 𝑺𝒉𝒙. 𝒚𝒓𝒆𝒇
𝟎 𝟏 𝟎
𝟎 𝟎 𝟏
• which transforms coordinate position as
x’ = x + Shx .(y-yref) & y’ = y
• Similarly, a y-direction shear relative to the y axis is
produced with the transformation matrix
𝟏 𝟎 𝟎
𝑺𝒉𝒚 𝟏 𝟎
𝟎 𝟎 𝟏
• which transforms coordinate position as
y’ = x . Shy + y & x’ = x
• We can generate y-direction shears relative to other
reference lines with
𝟏 𝟎 𝟎
𝑺𝒉𝒚 𝟏 − 𝑺𝒉𝒚. 𝒙𝒓𝒆𝒇
𝟎 𝟎 𝟏
• which transforms coordinate position as
x’ = x & y’ = shy(x - xref) + y
Raster Method of Transformation
• Raster systems store picture information as pixel patterns in the
frame buffer.
• Therefore, some simple transformations can be carried out
rapidly by simply moving rectangular arrays of stored pixel
values from one location to another within the frame buffer.
• Few arithmetic operations are needed, so the pixel
transformations are particularly efficient.
• Raster functions that manipulate rectangular pixel arrays are
generally referred to as raster ops.
• Moving a block of pixels from one location to another is also
called a block transfer of pixel values.
• On a bilevel svstem, this operation is called a bitBlt (bit-block
transfer), particularly when the function is hardware
implemented.
• The term pixBlt is sometimes used for block transfers on
multilevel systems (multiple bits per pixel).
• Translation performed as a block transfer of a raster area.
• All bit settings in the rectangular area shown are copied as a block into
another part of the raster.
• We accomplish this translation by first reading pixel intensities from a
specified rectangular area of a raster into an array,
• Then we copy the array back into the raster at the new location.
• The original object could be erased by filling its rectangular area with
the background intensity
• Typical raster functions often provided in graphics packages are:
copy - move a pixel block from one raster area to another.
read - save a pixel block in a designated array.
write - transfer a pixel array to a position in the frame buffer.
• Some implementations provide options for combining pixel values. In
replace mode, pixel values are simply transferred to the destination
positions.
• Other Options for combining pixel values include Boolean operations
(and, or, exclusive or) and binary arithmetic operations.
• With the exclusive or mode, two successive copies of a block to the
same raster area restores the values that were originally present in that
area.
• This technique can be used to move an object across a scene without
destroying the background.
• Rotations in 90-degree increments are easily accomplished
with block transfers.
• We can rotate an object 90" counterclockwise by first reversing
the pixel values in each row of the array, then we interchange
rows and columns.
• A 180" rotation is obtained by reversing.
• the order of the elements in each row of the array, then reversing
the order of the rows.
• Figure demonstrates the array manipulations necessary to rotate
a pixel block by 90" and by 180".
• For array rotations that
are not multiples of 90`,
we must perform more
computations.
• Each destination pixel
area is mapped onto the
rotated array and the
amount of overlap with
the rotated pixel areas is
calculated.
• An intensity for the
destination pixel is then
computed by averaging
the intensities of the
overlapped source
pixels, weighted by their
percentage of area
overlap.
• In Scaling we scale the pixel areas in the original block
using specified values for sx and sy and map the scaled
rectangle onto a set of destination pixels.
• The intensity of each destination pixel is then assigned
according to its area of overlap with the scaled pixel areas.
THANK YOU

You might also like