2-D Geometry
TRANSFORMATIONS
1
Some geometrical concepts
Cartesian Coordinates: Characterized by
•An axis of abscissae (x axis)
•An axis of ordinates (y axis)
•An Origin; intersection of x with y
A point on the plane is characterised by a
pair of real numbers P(x,y)
Y
a P (x,y)
x
i
s
X axis 2
Homogeneous Coordinates
The purpose of using homogeneous coordinates is to capture
the concept of infinity as we can’t represent the infinity with the
conventional Cartesian system.
We use two numbers a and w to represent a value v, v=a/w. If
w is not zero, the value is exactly a/w. Otherwise, we identify the
infinite value with (a,0). Therefore, the concept of infinity can be
represented with a number pair like (a, w).
Given a polynomial of degree n, after introducing w, all terms
are of degree n. Consequently, these polynomials are called
homogeneous polynomials and the coordinates (x,y,w) the
homogeneous coordinates.
3
For example
Suppose we have a line
Ax + By + C = 0.
Replacing x and y with x/w and y/w yields
A(x/w) + B(y/w) + C = 0.
Multiplying by w changes it to
Ax + By + Cw = 0.
Similarly, let the given equation be a second degree polynomial
Ax2 + 2Bxy + Cy2 + 2Dx + 2Ey + F = 0.
After replacing x and y with x/w and y/w and multiplying the
result with w2, we have
Ax2 + 2Bxy + Cy2 + 2Dxw + 2Eyw + Fw2 = 0 4
Converting Homogeneous to Cartesian
• Given a point (x,y,w) in homogeneous coordinates, its
corresponding point in the xy-plane is (x/w,y/w).
e.g. a point (3,4,5) in homogeneous coordinates
converts to point (3/5,4/5)=(0.6,0.8) in the xy-plane.
• Similarly, a point (x,y,z,w) in homogeneous coordinates
converts to a point (x/w,y/w,z/w) in space.
• Conversely, the homogeneous coordinates of a point
(x,y) in the xy-plane is simply (x,y,1). It is not unique. The
homogeneous coordinates of a point (x,y) in the xy-plane
is (xw, yw, w) for any non-zero w.
• Converting from a homogeneous coordinates to a
conventional one is unique; but, converting a
conventional coordinates to a homogeneous one is not.5
Transformation
It is the simulation of the manipulation of objects
in space by a graphics system is known as
Or
It is altering the coordinate description of an object
by changing orientation, size and shape of it.
Why are they important to graphics?
• moving objects on screen / in space
• mapping from model space to world space to
camera space to screen space
• specifying parent/child relationships
6
There are 2 types of transformation
Geometric – Object is transformed relative to
stationary coordinates.
Coordinate – Object is stationary and
coordinate system is transformed.
7
Geometric transformation
The basic geometric transformations are
Translation, Rotation and Scaling
Translation
A translation is applied to an object by
repositioning it along a straight line
path from one coordinate location to
another. We can translate a 2-D point ty
by adding translation distances tx and
ty to the original coordinate position
(x,y) to move the point to new position tx
(x’,y’) i.e.
x’ = x + tx & y’ = y + ty 8
The translation distance pair (tx,ty) is called
translation vector or shift vector
In Matrix form it can be written as follow
P= x P’= x’ T = tx
y y’ ty
P’=P + T
To change the position of a circle or ellipse,
we translate the center coordinates and
redraw the figure at new location
Translation is a rigid body transformation
9
Rotation
Rotation is applied to an object by
repositioning it along a circular path in the xy
plane. We specify a rotation angle and the
position of the rotation point (called pivot
point) about which the object is to be rotated.
+ve values of angle define counterclockwise
rotations
-ve values of angle define clockwise rotation.
10
Using trigonometric identities,
we can represent tranformed
coordinate as follow P’
X’= rcos(Θ+ Φ) (x’,y’)
= r cosΘcos Φ – r sinΘsinΦ
r P
Y’=rsin(Θ+ Φ) r
Θ (x,y)
= r cosΦsinΘ + r cosΘsinΦ Φ
Also
X= rcosΦ and Y=rsinΦ
Therefore
X’ = xcosΘ – ysinΘ
Y’= xsinΘ + ycosΘ 11
In matrix form P’
(x’,y’)
P’=R.P
r P
Where R = cosΘ -sinΘ r
Θ (x,y)
sinΘ cosΘ Φ
(Xr,yr)
Rotation of a point about an arbitrary pivot
position is given as
X’=xr + (x-xr)cosΘ – ( y-yr)sinΘ
Y’=yr + (x-xr)sinΘ + (y-yr)cosΘ
12
Rotation is a rigid body transformation
Scaling
A scaling transformation alter the size of an
object
The operation
can be carried
out by multiplying
coordinate
values by scaling
factor.
X’ = x.sx and Y’ = y.sy
X’ = sx 0 x
Y’ 0 sy y 13
Uniform scaling : when both sx
and sy have same value
Differential scaling : when both
sx and sy have different values.
14