2d Transformations 1-Computer Graphics-Lecture Notes, Study notes of Computer Graphics

Computer Graphics involves technology to accept, process, transform and present information in a visual form that also concerns with producing images and animations using a computer. This course teach how to make your own design in 2d and 3d using OpenGl. This lecture includes: Transformations, Translation, Rotation, Scaling, Primitive, Animation, Geometery, Orientation

Typology: Study notes

2011/2012

Uploaded on 08/04/2012

parnashi
parnashi ๐Ÿ‡ฎ๐Ÿ‡ณ

4.4

(49)

71 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
L
Le
ec
ct
tu
ur
re
e
N
No
o.
.1
11
1
2D Transformations I
In the previous lectures so far we have discussed output primitive as well as filling
primitives. With the help of them we can draw an attractive 2D drawing but that will be
static whereas in most of the cases we require moving pictures for example games,
animation, and different model; where we show certain objects moving or rotating or
changing their size.
Therefore, changes in orientation that is displacement, rotation or change in size is called
geometric transformation. Here, we have certain basic transformations and some special
transformation. We start with basic transformation.
Basic Transformations
Translation
Rotation
Scaling
Above are three basic transformations. Where translation is independent of others
whereas rotation and scaling depends on translation in most of cases. We will see how in
their respective sections but here we will start with translation.
Translation
A translation is displacement from original
place. This displacement happens to be
along a straight line; where two distances
involves one is along x-axis that is tx and
second is along y-axis that is ty. The same
is shown in the figure also we can express
it with following equation as well as by
matrix:
x๎˜‚ = x + tx , y๎˜‚ = y + ty
Here (tx, ty) is translation vector or shift
vector. We can express above equations as a single matrix equation by using column
vectors to represent coordinate positions and the translation vector:
P๎˜‚ = P + T
Where P = P๎˜‚= T =
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 can be translated by applying the above transformation equation to each of
the line endpoints and redrawing the line between the new coordinates. Similarly a
docsity.com
pf3
pf4

Partial preview of the text

Download 2d Transformations 1-Computer Graphics-Lecture Notes and more Study notes Computer Graphics in PDF only on Docsity!

LeLeccttuurree NNoo..1 111 2D Transformations I

In the previous lectures so far we have discussed output primitive as well as filling primitives. With the help of them we can draw an attractive 2D drawing but that will be static whereas in most of the cases we require moving pictures for example games, animation, and different model; where we show certain objects moving or rotating or changing their size.

Therefore, changes in orientation that is displacement, rotation or change in size is called geometric transformation. Here, we have certain basic transformations and some special transformation. We start with basic transformation.

Basic Transformations

Translation Rotation Scaling

Above are three basic transformations. Where translation is independent of others whereas rotation and scaling depends on translation in most of cases. We will see how in their respective sections but here we will start with translation.

Translation A translation is displacement from original place. This displacement happens to be along a straight line; where two distances involves one is along x-axis that is tx and second is along y-axis that is ty. The same is shown in the figure also we can express it with following equation as well as by matrix:

x = x + tx , y = y + ty

Here (tx , ty) is translation vector or shift vector. We can express above equations as a single matrix equation by using column vectors to represent coordinate positions and the translation vector:

P = P + T

Where P = P= T =

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 can be translated by applying the above transformation equation to each of the line endpoints and redrawing the line between the new coordinates. Similarly a

docsity.com

polygon can be translated by applying the above transformation equation to each vertices of the polygon and redrawing the polygon with new coordinates. Similarly curved objects can be translated. For example to translate circle or ellipse, we translate the center point and redraw the same using new center point.

Rotation A two dimensional rotation is applied to an object by repositioning it along a circular path in the xy plane. To rotate a point, its coordinates and rotation angle is required. Rotation is performed around a fixed point called pivot point. In start we will assume pivot point to be the origin or in other words we will find rotation equations for the rotation of object with respect to origin, however later we will see if we change our pivot point what should be done with the same equations.

Another thing is to be noted that for a positive angle the rotation will be anti-clockwise where for negative angle rotation will be clockwise.

Now for the rotation around the origin as shown in the above figure we required original position/ coordinates which in our case is P(x,y) and rotation angle . Now using polar coordinates assume point is already making angle  from origin and distance of point from origin is r, therefore we can represent x and y in the form:

x = r cos and y = r sin

Now if we want to rotate point by an angle , we have new angle that is (+ ), therefore now point P(x,y) can be represented as:

x = r cos( + ) = r cos cos โ€“ r sin sin and y = r sin( + ) = r cos sin + r sin cos

Now replacing r cos = x and r sin = y in above equations we get:

x = x cos โ€“ y sin and y= x sin + y cos

Again we can represent above equations with the help of column vectors:

P= R. P Where

docsity.com

factor S (^) y. Therefore, following equations can be expressed:

x = x.S (^) x y = y.S (^) y In matrix form it can be expressed as:

P = S.P

Now we may have different values for scaling factor. Therefore, as it is multiplying factor therefore, if we have scaling factor > 1 then the object size will be increased than original size; whereas; in reverse case that is scaling factor < 1 the object size will be decreased than original size and obviously there will be no change occur in size for scaling factor equal 1.

Two variations are possible in scaling that is having scaling factors to be kept same that is to keep original shape; which is called uniform scaling having Sx factor equal Sy factor. Other possibility is to keep Sx and Sy factor unequal that is called differential scaling and that will alter the original shape that is a square will no more remain square.

Now above equation of scaling can be applied to any line, circle and polygon etc. However, as in case of line and polygon we will scale ending points or vertices then redraw the object but in circle or ellipse we will scale the radius.

Now coming to the point when scaling with respect to any point other then origin, then same methodology will work that is to apply translation before scaling and retranslation after scaling. So here if we consider fixed/ pivot point (xf ,y (^) f ), then following equations will be achieved:

x = x (^) f + (x - x (^) f )S (^) x y = y (^) f + (y - y (^) f )S (^) y

These can be rewritten as:

x = x. S (^) x + xf (1 โ€“ S (^) x) y = y. S (^) y + y (^) f (1 โ€“ S (^) y)

Where the terms x (^) f (1 โ€“ Sx ) and y (^) f (1 โ€“ S (^) y) are constant for all points in the object.

docsity.com