You are on page 1of 460

DTEIT 19/8/

CG-6284

GEOMETRICAL
TRANSFORMATIONS

This section introduces the basic 2-D and 3-D


geometrical transformations used in computer
graphics.
In general, many applications use the geometric
transformations to change the

position,

orientation &

size of objects in a drawing.

DTEIT 19/8/

CG-6284

GEOMETRICAL
TRANSFORMATIONS
Example
A city planning application program would use
translation to place symbols for buildings &
trees at appropriate

positions,

rotation to orient the symbols &

scaling to size the symbols.

DTEIT 19/8/

CG-6284

GEOMETRIC
TRANSFORMATIONS

CHANGES IN

ORIENTATION,

SIZE AND

SHAPE ARE ACCOMPLISHED WITH


GEOMATRIC TRANSFORMATIONS THAT ALTER
THE COORDINATE DESCRIPTIONS OF OBJECTS.

DTEIT 19/8/

CG-6284

GRAPHICS TRANSFORMATIONS
Computer graphics system is the ability to
simulate both
the movement and
the manipulation of the objects in the plane.
These process are described in terms of
translations,
rotations,
scaling and
reflections.
DTEIT 19/8/

CG-6284

GEOMETRIC TRANSFORMATIONS

The mathematical statement of the

viewpoint

is

described

by

geometric

transformations applied to each point of the


object.

This effect is attained through the

application of coordinate transformations.

DTEIT 19/8/

CG-6284

GEOMETRIC TRANSFORMATIONS

Let us impose a coordinate system on a

plane.

An object obj in the plane can be

considered as a set of points.

Every set point p has coordinates ( x, y )

and so the object is the sum total of all its


coordinate points.
DTEIT 19/8/

CG-6284

Every set point p has coordinates ( x, y ) and


so the object is the sum total of all its
coordinate points.
Y

OBJECT

P(X,Y)

DTEIT 19/8/

CG-6284

GEOMETRIC TRANSFORMATIONS

If the object is moved to a new position,

it can be regarded as a new object obj ,

all of whose coordinate points p can be

obtained from the original points p by the


application of a geometric transformation.

DTEIT 19/8/

CG-6284

GEOMETRIC TRANSFORMATIONS
Y

1
P(1,1/2 )
1/2
O
DTEIT 19/8/

1
CG-6284

X
10

BASIC TRANSFORMATIONS
BASIC GEOMETRIC TRANSFORMATION
ARE

1. TRANSLATION,

2. ROTATION,

3. SCALING.

DTEIT 19/8/

CG-6284

11

BASIC TRANSFORMATIONS

TRANSLATION

A translation is applied to an object by a


repositioning it along a straight line path from
one co-ordinate location to another.

In translation , an object is displaced a


given distance and direction from its original
position.

DTEIT 19/8/

CG-6284

12

TRANSLATE A 2-D POINT


We translate a 2 dimensional point by adding translation
distance, tx and ty to the original co-ordinate position

(x,y) to move the point to a new position (x`,y`)


x`=x+ tx ,
y`=y+ty
translation distance pair (tx , ty ) is called the
translation
vector
or
shift
vector.

DTEIT 19/8/

CG-6284

13

TRANSLATION
If the displacement is given by the
vector
v=txi + tyj ,
The new object point p(x,y) can be
found by applying the transformation tv to
p(x,y)
p=tv(p)
where x=x+tx and y=y+ty
DTEIT 19/8/

CG-6284

14

TRANSLATION
OBJ

P
V
Y

P
OBJ

DTEIT 19/8/

CG-6284

15

TRANSLATING A POINT
TRANSLATING A POINT
FROM POSTION P TO P`
WITH
TRANSLATION
VECTOR T.

p`
T
p
X

p = (x1, x2)
p = (x1, x2)
t = (tx, ty)
DTEIT 19/8/

CG-6284

16

TRANSLATING A POINT

This allow us to write the 2-D.

Translation location in matrix form


P`=P + T

Translation is a rigid body transformation


that moves objects without deformations.
# Every point on the object is translated by
the same amount.
DTEIT 19/8/

CG-6284

17

MOVING A POLYGON
MOVING A POLYGON FROM POSITION P1 TO
POSITION P2 WITH THE TRANSLATION
VECTOR (4.90, 5.10).
20

20

15

15

10

10

5
5

DTEIT 19/8/

10

15

20

CG-6284

10

15

20

18

TRANSLATING CURVED
SURFACE
Similar methods are used to translate
curved objects.
To change the position of a circle or
ellipse
we translate the center coordinate
and redraw the figure in the new location

DTEIT 19/8/

CG-6284

19

ROTATION

A two dimensional rotation is applied to


an object by repositioning it along circular
path in the x, y plane.

To generate a rotation

we specific rotation angle and the


position(xr, yr) of the rotation point or (pivot
point) about which the object is to be rotated .

DTEIT 19/8/

CG-6284

20

ROTATION
Rotation of an object through
angle about the pivot point (xr,yr)
p

yr

p
xr

DTEIT 19/8/

CG-6284

21

ROTATION

Positive values for the rotation angle define


counterclockwise rotations about the pivot point .

Negative values rotate objects in the


clockwise direction.

This kind of transformation can also be


described as a rotation about a rotation axis.
This axis is perpendicular to the xy plane and
passes through the pivot point.

DTEIT 19/8/

CG-6284

22

ROTATION

We first determine the transformation


equation for rotation of a point position P when
the pivot point is at the coordinate origin.

The angular and coordinate relationships of


the original and transformed point position are
show in the next slide.

DTEIT 19/8/

CG-6284

23

ROTATION

(x.y)
r

DTEIT 19/8/

(x.y)

Rotation of a point from


position (x,y) to position (x,y)
through an angle relative to
the coordinate origin. The
original angular displacement of
the point from the x axis is

CG-6284

24

ROTATION
In the previous slide ,
r is the constant distance of the point
from the origin ,
angle is the original angular
position of the point from the horizontal ,
and
is the rotation angle.
DTEIT 19/8/

CG-6284

25

ROTATION

Using

standard
trigonometric
identities we can
express
the transformed
coordinates in terms of angles and
x = rcos(+)
= rcos cos- rsin sin
y = rsin(+)
= rcos sin - rsin cos

DTEIT 19/8/

CG-6284

26

ROTATION
The
original co- ordinates
polar coordinate are

of the point

in

x = rcos,
y = rsin
Substituting (2) in (1)
we obtain the trans formation equation for rotating a point at
position (x,y) through an angle q about the origin

so, x=xcos - ysin


y=xsin + ycos

DTEIT 19/8/

CG-6284

27

ROTATION
WE CAN WRITE THE ROTATION EQUATION IN THE
MATRIX FORM

P = R.P
WHERE THE ROTATION MATRIX IS

cos-

R =

sinsin
cos

DTEIT 19/8/

CG-6284

28

ROTATION ABOUT THE ORIGIN


In rotation, the object is rotated degree
about the origin.

The convention is that the direction of


rotations
counterclockwise if is a positive angle
and

clockwise if is a negative angle.

DTEIT 19/8/

CG-6284

29

ROTATION ABOUT THE ORIGIN

The transformation of rotation R is


P=R (P)

WHERE
X=X COS ( )- Y SIN ( ) AND
Y=X SIN ( ) + Y COS ( ).
DTEIT 19/8/

CG-6284

30

ROTATION ABOUT THE ORIGIN

Y
OBJ

OBJ

DTEIT 19/8/

CG-6284

31

SCALING
A scaling transformation alters the size of an
object.
This operation can be carried out for polygons
by multiplying the coordinate value (x,y) of each
vertex by scaling factors sx and sy to produce the
transformed coordinates (x,y)
x=x. sx ,
y= y. sy

DTEIT 19/8/

CG-6284

32

SCALING

Scaling factor sx scales object in the x

direction ,while sy scales in the y direction.

The transformation equation can also be written

in the matrix form.


(x,y) = {(sx, 0), (0, sy)}. {x,y}
or
P=S.P
WHERE S IS THE 2 BY 2 SCALING MATRIX .

DTEIT 19/8/

CG-6284

33

SCALING
POINTS CAN BE SCALED BY SX SLONG
THE X AXIS AND SY ALONG THE Y AXIS INTO
NEW POINTS BY MULTIPLICATIONS
x = sx.x,

y = sy.y

IN THE MATRIX FORM, THIS IS


X
Y

DTEIT 19/8/

Sx
0

0
Sy

OR

P = S . P

CG-6284

34

SCALING
Any positive numeric values can be assigned to
the scaling factors sx and sy .

Values less than 1 reduce the size of objects.

Values greater than 1 produce an enlargement.

Specifying a value of 1 for both sx and sy


leaves the size of objects unchanged.

DTEIT 19/8/

CG-6284

35

SCALING
When sx and sy are assingned the same value , a

uniform scaling is produced that maintain relative


object proportions.

Unequal values for sx and sy result in a

differential scaling that

is often used in

design

Application.

DTEIT 19/8/

CG-6284

36

SCALING

Scaling factors

with values less than 1 move object

closer to the coordinate origin,

while values greater than 1 move

coordinate positions farther from the origin.

DTEIT 19/8/

CG-6284

37

SCALING
Turning a square (a)
into a rectangle (b) with
scaling factors

sx=2

and sy=1

DTEIT 19/8/

(a)

(b)

CG-6284

38

SCALING WITH RESPECT OF THE


ORIGIN

Scaling is the process of expanding or

compressing the dimensions of an object.

Positive scaling constants sx and sy are

used to describe changes in the length with


respect to the x direction and y direction,
respectively.

DTEIT 19/8/

CG-6284

39

SCALING WITH RESPECT OF


THE ORIGIN
After a scaling transformation is
performed, the new object is located at
a different position relative to the
origin.
In a scaling transformation the only
point that remain fixed is the origin.
DTEIT 19/8/

CG-6284

40

Scaling transformation with scaling


factors sx=2 and sy=0.5
Y
2

1
1/2

1
1

DTEIT 19/8/

P
12

CG-6284

4 X

41

SCALING
If both scaling constants have the
same value s , the scaling
transformation is said to be
homogeneous.
If s< 1, then it is a reduction.
If s >1, it is a magnification
DTEIT 19/8/

CG-6284

42

HOMOGENOUS COORDINATES
To express any 2-D transformation as a
matrix multiplication,

we represent each Cartesian coordinate


position (x, y) with the Homogeneous
coordinate triple (xh, yh, h), where

x=xh/h,
y=yh/h
DTEIT 19/8/

CG-6284

43

HOMOGENOUS COORDINATES
A general homogeneous coordinate representation can also
be written as
(h.x, h.y, h).
For 2D geometric transformations,

we can choose the homogeneous parameter h to be any


non zero value.
A convenient choice is simply to set h=1.

Each 2D position is then represented with homogeneous


coordinates (x, y, 1).

DTEIT 19/8/

CG-6284

44

HOMOGENOUS COORDINATES
The term homogeneous coordinates is
used in mathematics to refer to the fact of
this representation on Cartesian equation.

When a Cartesian point (x, y) is


converted to a homogeneous representation
(xh, yh, h),

DTEIT 19/8/

CG-6284

45

HOMOGENOUS COORDINATES
Equations containing x & y,
such as f(x, y)=0 become homogeneous
equation in the 3 parameters xh, yh & h.
Expressing positions in homogeneous
coordinates allow us to represent all
geometric transformation equations as
matrix multiplication's.

DTEIT 19/8/

CG-6284

46

HOMOGENOUS COORDINATES
For translation, we have :
X
Y
1

DTEIT 19/8/

tx

1 ty

CG-6284

Y
1

47

HOMOGENOUS COORDINATES

which we can write in the abbreviated form :

P=T(tx, ty).P
with T(tx, ty) as the 3 by 3 translation matrix.

The inverse of the translation matrix is


obtained by replacing the translation parameters
tx & ty with their negative : -tx & -ty.

DTEIT 19/8/

CG-6284

48

HOMOGENOUS COORDINATES

Similarly, rotation transformation equation about the coordinate origin are now written as :

or as :

P=R( ).P

cos -sin

X
Y
1

DTEIT 19/8/

sin
0

cos 0
0

CG-6284

Y
1

49

HOMOGENOUS COORDINATES
The rotation transformation operator R(t)
is the 3 x 3 matrix, with rotation parameter

We get the inverse rotation matrix when


theta is replaced with -

Finally, a scaling transformation relative


to the coordinate origin is now expressed as
the matrix multiplication.

DTEIT 19/8/

CG-6284

50

HOMOGENOUS COORDINATES
Expressed as the matrix multiplication.
X
Y
1

DTEIT 19/8/

sx

sy

CG-6284

Y
1

51

HOMOGENOUS COORDINATES
Or :

p=s(sx, sy).P

Where s(sx, sy) is the 3 x 3 matrix with


parameters sx & sy replacing these
parameters with their multiplicative inverse
(1/sx & 1/sy) yields the inverse scaling
matrix.
DTEIT 19/8/

CG-6284

52

OTHER
TRANSFORMATIONS
Some packages provide a few
additional transformation that are
useful in certain application.
Two such transformations are
reflection and
shear.
DTEIT 19/8/

CG-6284

53

REFLECTION

REFLECTION :
A reflection is a

transformation that

produces a mirror image of an object.

The mirror image for a two-dimensional

reflection is generated relative to an axis of


reflection by rotating the object 180 degree
about the reflection axis.
DTEIT 19/8/

CG-6284

54

REFLECTION
1

ORIGINAL
POSITION

x
REFLECTED
POSITION

1
REFLECTION OF AN OBJECT ABOUT THE X AXIS.
DTEIT 19/8/

CG-6284

55

REFLECTION
REFLECTION ABOUT THE LINE y=0,
THE x AXIS, IS ACCOMPLISHED WITH
THE TRANSFORMATION MATRIX.

DTEIT 19/8/

-1

1
CG-6284

56

REFLECTION
A REFLECTION ABOUT THE y AXIS
FLIPS
x
COORDINATES
WHILE
KEEPING y COORDINATES THE SAME.
THE MATRIX FOR THIS TRANSFORMATION IS :

DTEIT 19/8/

-1

CG-6284

57

REFLECTION
THE CHANGE IN POSITION OF AN
OBJECT THAT HAS BEEN REFLECTED
ABOUT
THE
LINE
x=0.
THE
EQUIVALENT ROTATION IN THIS CASE
IS 180 DEGREE.
y
ORIGINAL
REFLECTED
Reflection of an
object about the y
axis.
DTEIT 19/8/

POSITION
2

POSITION
2
1

1
3

CG-6284

58

REFLECTION
We flip both the x & y coordinates of a
point by reflecting relative to an axis that is
perpendicular to the xy plane and that
passes through the coordinates origin.

THE REQUIRED MATRIX IS:

DTEIT 19/8/

CG-6284

-1

59

REFLECTION
y

REFLECTED
POSITION
2
x

1
2
ORIGINAL
POSITION

REFLECTION OF AN OBJECT RELATIVE TO AN


AXIS PERPENDICULAR TO THE xy PLANE &
PASSING THROUGH THE COORDINATE ORIGIN.
DTEIT 19/8/

CG-6284

60

REFLECTION

TO
ENVISION
THE
ROTATION
TRANSFORMATION PATH FOR ITS REFLECTION
1. THE FLAT OBJECT MOVING OUT OF THE xy
PLANE .
2. ROTATING 180 DEGREE THROUGH 3-D
SPACE ABOUT x- AXIS.
3. BACK INTO THE xy PLANE ON THE OTHER
SIDE OF x AXIS.
DTEIT 19/8/

CG-6284

61

MIRROR REFLECTION ABOUT AN


AXIS

If either the x or y axis is treated as a


mirror, the object has a mirror image or
reflection.
Since the reflection P of an object point P
is located the same distance from the mirror as P,
the mirror reflection transformation m, about the
x axis is given by
P=mx(P)
DTEIT 19/8/

CG-6284

62

Where x=x and y= -y


Similarly, the mirror reflection about the y axis is
P=my(P)
Where x= -x and y= y.
Y
P (-X,Y)

P(X,Y)
X
P (X, -Y)

DTEIT 19/8/

CG-6284

63

SHEAR

A transformation that distorts the shape of an object such


that the transformed shape appears as if the object were
composed of internal layers that had been caused to slide
over each other is called a shear.

Two common shearing transformations are those that shift


coordinate x values and those that shift y values.

DTEIT 19/8/

CG-6284

64

SHEAR
An x-direction shear relative to the x axis
produced with the transformation matrix .
Which transforms coordinate
positions as
x=x+shx.y
1 shx 0
y=y
0 1 0

0
DTEIT 19/8/

CG-6284

1
65

SHEAR
y
(0,1)
(0,0)

(.5,1)

(1,1)
(1,0)

(0,0)

(1.5,1)

(1,0)

A SQUARE IS CONVERTED TO A PARALLELOGRAM


USINGTHE X_DIRECTION SHEAR MATRIX WITH
Shx=2
DTEIT 19/8/

CG-6284

66

INVERSE GEOMATRIC
TRANSFORMATION

Each geometric transformation has an

inverse which is described by the opposite


operation performed by the transformation.

Translation :

tv-1 = t-v , or translation in the opposite


direction.
DTEIT 19/8/

CG-6284

67

INVERSE GEOMATRIC
TRANSFORMATION
Rotation :
rr, or rotation in the opposite direction.
Scaling :
s-1sx,xy = s1/sx, 1/sy
Mirror reflection :
m-1x= mx and m-1y =my

DTEIT 19/8/

CG-6284

68

COORDINATE
TRANSFORMATION
Suppose that we have two coordinate
systems in the plane.

The first system is located at origin o


and has coordinate axes xy.

The second coordinate system is located


at origin o and has coordinate axes xy.

DTEIT 19/8/

CG-6284

69

COORDINATE
TRANSFORMATION

Now each point in the plane has two


coordinate descriptions :
(x,y) and (x,y), depending on
which coordinate system is used.
We can describe this transformation by
determining how the (x,y) coordinates of a
point p are related to the (x,y) coordinates
of the same point.
DTEIT 19/8/

CG-6284

70

COORDINATE TRANSFORMATION
Y

DTEIT 19/8/

P(X,Y)
(X,Y)

CG-6284

71

COORDINATE TRANSFORMATION
P(x,y)
(x,y)

X
O

DTEIT 19/8/

CG-6284

72

TRANSLATION
If the xy coordinate system is displayed to a new
position,

where the direction of the displacement is given by


the vector v=txi+ty,

the coordinates of a point in both systems are


related by the translation transformation t v . (x, y ) =

tv (x, y)
where x=x-tx and y=y-ty

DTEIT 19/8/

CG-6284

73

ROTATION ABOUT THE


ORIGIN

The xy system is rotated degree about


the origin.
Then the coordinates of a point in both
systems are related
by the rotation
transformation r :
(x, y )= r (x,y)
Where x =x cos () + y sin () and
y = -x sin () + y cos ().
DTEIT 19/8/

CG-6284

74

SCALING WITH RESPECT TO


THE ORIGIN
Suppose that a new coordinate system is
formed by leaving the origin and coordinate
axes unchanged, but introducing different
units of measurement along the

x and
y axes.

DTEIT 19/8/

CG-6284

75

SCALING WITH RESPECT TO THE ORIGIN


If the new units are obtained from
the old unit by a scaling of
sx units along the x axis and
sy unit along the y axis,
The coordinates in the new system
are related to coordinate in the old
system
through
the
scaling
transformation ssx,sy .
DTEIT 19/8/

CG-6284

76

SCALING WITH RESPECT TO


THE ORIGIN
(x,y) = ssx,sy (x,y).

OLD UNIT

where x=1/sx.x and


y=1/sy.y.

Y
2
P(2,1)

1
O
DTEIT 19/8/

CG-6284

2
77

SCALING WITH RESPECT TO THE ORIGIN

The figure shows coordinate


scaling transformation using
scaling factors sx = 2 and sy
= 1/2

1/2

P(2,1/2)

NEW UNIT

O
DTEIT 19/8/

2
CG-6284

X
78

MIRROR REFLECTION
ABOUT AN AXIS

If the new coordinate system

is obtained by the reflecting the old


system about either x or y axis, the
relationship between the coordinates is
given by the coordinate transformation
mx and my.
DTEIT 19/8/

CG-6284

79

MIRROR REFLECTION ABOUT AN AXIS


For reflection about the x axis
(x,y) = mx(x,y)
where x= x and y= -y.
For reflection about the y axis
(x,y) = my (x,y)
where x= -x and y =y.

DTEIT 19/8/

CG-6284

80

INVERSE COORDINATE
TRANSFORMATION
Each coordinate transformation has
an inverse which can be found by
applying the opposite transformation.

Translations:
t-1v =t-v , translation in the opposite

direction .
DTEIT 19/8/

CG-6284

81

INVERSE COORDINATE
TRANSFORMATION

ROTATION :

R -1RROTATION IN THE OPPOSITE


DIRECTION.

SCALING :

S-1SX,SY = S1/SX,1/SY

MIRROR REFLECTION :

MX= MX AND MY =MY


DTEIT 19/8/

CG-6284

82

COMPOSITE
TRANSFORMATIONS
We can set up a matrix for any
sequence of
transformations as a
composite transformation matrix by

calculating the matrix product of


individual transformations.

DTEIT 19/8/

CG-6284

83

COMPOSITE
TRANSFORMATIONS
FORMING
PRODUCTS
TRANSFORMATION MATRICES
OFTEN REFFFERED TO AS A

CONCATENATION OR

COMPOSITION OF MATRICES.

DTEIT 19/8/

CG-6284

OF
IS

84

TRANSLATION
If two successive translation vectors (tx1, ty1)
and (tx2, ty2) are applied to the coordinate
position p,

The final transformed location p is


calculated as :

P= T(tx2, ty2) .{T(tx1, ty1). P}


= {T(tx2, ty2) .T(tx1, ty1)}. P
DTEIT 19/8/

CG-6284

85

TRANSLATION

Where p & p are represented as

homogenous co-ordinate column vectors.

The composite transformation matrix

for this sequence of translation is

DTEIT 19/8/

CG-6284

86

TRANSLATION

OR

tx2

ty2

tx1

ty1

tx1+tx2

ty1+ ty2

T(tx2, ty2) .T(tx1, ty1)= T(tx2+ tx1, ty1+ ty2)

It demonstrates that two successive


transformations are additive.
DTEIT 19/8/

CG-6284

87

ROTATIONS

Two successive rotations applied to point p produce

the transformed position :

P = r(r(p}
= {R(r(p
DTEIT 19/8/

CG-6284

88

ROTATIONS

By

multiplying

the

two

rotation

matrices, we can verify that two successive


rotations are additive.

R(r(=r(+
P=r(+p
DTEIT 19/8/

CG-6284

89

SCALING

Concatenat transformation matrices for

two successive scaling operations produces


the following composite scaling matrice :
sx2 0

sy2 0

DTEIT 19/8/

Sx1 0

sy1 0

sx1+sx2

0
0

CG-6284

sy1+sy2 0
0

90

SCALING
OR
S(sx2, sy2) . S(sx1, sy1) = S(sx1. sx2, sy1. sy2)

The resulting matrix in this case

indicates that successive scaling operations


are multiplicative .
DTEIT 19/8/

CG-6284

91

GENERAL PIVOT POINT


ROTATION

With a graphics package that only

provides

a rotate function for revoluting

objects about the coordinate origin,

we can generate rotations about any

selected pivot point (xr1, yr1) by performing


DTEIT 19/8/

CG-6284

92

GENERAL PIVOT POINT


ROTATION
The following sequence of translate-rotatetranslate operations :

1. Translate the object so that the pivot

point position is moved to the coordinate


origin.
DTEIT 19/8/

CG-6284

93

GENERAL PIVOT POINT


ROTATION

2.

Rotate the object about the

coordinate origin.

3. Translate the object so that the pivot

point is returned to its original position.

DTEIT 19/8/

CG-6284

94

GENERAL PIVOT POINT


ROTATION

ORIGINAL
POSITION OF
OBJECT &
PIVOT POINT

TRANSLATION
OF OBJECT SO
THAT PIVOT
POINT(xr1, yr1) IS

ROTATION
ABOUT ORIGIN

AT ORIGIN

TRANSLATION
OF OBJECT SO
THAT PIVOT
POINTIS
RETURNED TO
POSITION
(xr1,
yr1).

DTEIT 19/8/

CG-6284

95

GENERAL PIVOT POINT


ROTATION
The composite transformation matrix
for this sequence is obtained with the
concatenation :

xr

yr

cos

sincos
0

cos

-sin

sincos
0

DTEIT 19/8/

-sin

0
0

xr

yr

xr(1- cos)+ yr sin


yr(1- cos)+ xr sin

CG-6284

96

GENERAL FIXED POINT


SCALING
Previous figure
illustrates 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.

DTEIT 19/8/

CG-6284

97

GENERAL FIXED POINT


SCALING

1. Translate object so that the coincide

with the coordinate origin.

2. Scale the object with respect to the

coordinates origin.

DTEIT 19/8/

CG-6284

98

GENERAL FIXED POINT


SCALING
3. Use the inverse translation of step
1 to return the object to its original
position.

Concatenating the matrix for these


three operations produce the required
scaling matrix.

DTEIT 19/8/

CG-6284

99

GENERAL FIXED POINT


SCALING

ORIGINAL
POSITION OF
OBJECT &
FIXED POINT

TRANSLATION
OF OBJECT SO
THAT FIXED
POINT(xr1, yr1) IS

SCALE OBJECT
WITH RESPECT
TO ORIGIN

AT ORIGIN

TRANSLATION
OF OBJECT SO
THAT FIXED
POINTIS
RETURNED TO
POSITION
(xr1,
yr1).

DTEIT 19/8/

CG-6284

100

GENERAL FIXED POINT


SCALING
1

xf

sx 0

-xf

yf

sy

-yf

sx 0

xf (1- sx)

sy

yf(1- sx)

OR

T(xf, yf).S(sx, sy).T(-xf, -yf) = S((xf, yf, sx, sy)


DTEIT 19/8/

CG-6284

101

GENERAL SCALING
DIRECTIONS

If we want to apply scaling factors with

values specified by parameters s1 & s2 in the


directions.

To accomplish the scaling without

changing the orientation of object, we first


DTEIT 19/8/

CG-6284

102

GENERAL SCALING
DIRECTIONS

Perform a rotation so that the

directions for s1 & s2 coincide with the x & y


axis, respectively.

Then the scaling transformation is

applied, followed by an opposite rotation to


return points to their original orientation.
DTEIT 19/8/

CG-6284

103

GENERAL SCALING
DIRECTIONS

The composite matrix resulting from the

product of these 3 transformations is :


R-1.S(s,sR( =
S1cos2 +S2sin2

(S2-S1)cossin0

(S2-S1)cossinS1sin2 +S2cos20
0
DTEIT 19/8/

0
CG-6284

1
104

GENERAL SCALING
DIRECTIONS
(1/2, 3/2)
(0, 1)

(2, 2)

(1, 1)
(3/2, 1/2)

(0, 0)

(1, 0)

(0, 0)

USING SCALING TRANSFORMATION, WE


TURN A SQUARE INTO A PARALLELOGRAM BY
STRECHING IT ALONG THE DIAGONAL FROM
(0, 0) TO (1, 1).
DTEIT 19/8/

CG-6284

105

GENERAL COMPOSITE
TRANSFORMATIONS
A general 2-d transformation ,
representing a combination of

TRANSLATIONS,

ROTATIONS &

SCALINGS can be expressed as :

DTEIT 19/8/

CG-6284

106

GENERAL COMPOSITE
TRANSFORMATIONS

X
Y
1

DTEIT 19/8/

rsxx

rsyy trsx

rsyx

rsyy trsy

CG-6284

Y
1

107

GENERAL COMPOSITE
TRANSFORMATIONS

The

four

elements

rsij

are

the

multiplicative rotation scaling terms in the


transformations that involve only

ROTATION ANGLES &

SCALING FACTORS.

DTEIT 19/8/

CG-6284

108

GENERAL COMPOSITE
TRANSFORMATIONS

Elements trsx & trsy are the transnational

terms containing combinations of

translation distances, pivot point & fixed

point coordinates &

rotation angles & scaling parameters.

DTEIT 19/8/

CG-6284

109

GENERAL COMPOSITE
TRANSFORMATIONS
e.g. If an object is to be scaled & rotated
about its

centroid coordinate (xc, yc) &

then translated.

The values for the elements of the composite


transformation matrix are .
DTEIT 19/8/

CG-6284

110

GENERAL COMPOSITE
TRANSFORMATIONS
T(tx, ty).R(xc, yc,S(xc, yc, sx, sy) =
sxcos -sysin
sxsinsycos
0

xc(1-sxcosycsysintx
yc(1-sycosxcsxsinty

REVERSING THE ORDER IN WHICH


SEQUENCE
OF
TRANSFORMATIONS
PERFORMED POSITION OF AN OBJECT.
DTEIT 19/8/

CG-6284

A
IS
111

ALGORITHM
IDENTITY-MATRIX(H):- Routine to create the identity
transformation
ARGUMENT

H is the transformation array of 3*2

elements.
LOCAL

I , J variables for stepping through

the H array

BEGIN

DTEIT 19/8/

CG-6284

112

ALGORITHM
FOR I = 1 TO 3 DO
FOR J = 1 TO 2 DO
IF I = J THEN H [I , J]<-- 1
ELSE H [ I ,J]<-- 0;
RETURN;
END;
DTEIT 19/8/

CG-6284

113

ALGORITHM
It has the effect of multiplying the matrix H
on the right by a scaling transformation matrix
of

DTEIT 19/8/

SX

SY

1
CG-6284

114

ALGORITHM

MULTIPLY-IN-SCALE (SX,SY,H):- Routine


to post-multiply the transformation matrix by a
scale transformation
ARGUMENTS

SX is the x scale factor

SY is the y scale factor


H is a 3*2 transformation
DTEIT 19/8/

CG-6284

matrix
115

ALGORITHM
LOCAL I for stepping through the array
BEGIN
FOR I = 1 TO 3 DO
BEGIN
H [I, 1]<-- H[I, 1]*SX
H [I, 2]<-- H[I, 2]*SY
END;
RETURN;
END;
DTEIT 19/8/

CG-6284

116

ALGORITHM
For translation TX, TY ,we post-multiply
H by the translation matrix
1

TX
DTEIT 19/8/

TY

1
CG-6284

117

ALGORITHM

Again we simplify the multiplication by

neglecting zero terms.

Since

the

third

column

of

the

transformation matrix is always 0,0,1,the


algorithm for translation is as follows.
DTEIT 19/8/

CG-6284

118

ALGORITHM

MULTIPLY-IN-TRANSLATION(TX,TY,H):- Routine
to post-multiply the transformation matrix by a translation

ARGUMENTS TX translation in the x direction


TY translation in the y direction
H a 3*2 transformation matrix
BEGIN

DTEIT 19/8/

CG-6284

119

ALGORITHM
H[3,1]<-- H[3,1] + TX;
H[3,2]<-- H[3,2] + TY;
RETURN;
END;

DTEIT 19/8/

CG-6284

120

ALGORITHM
For a rotation of A radians counter
clockwise, we post-multiply by

COS A

SIN A

-SIN A

COS A

0
DTEIT 19/8/

CG-6284

121

ALGORITHM

The algorithm takes the angle as an

argument ,

calculates the sine and cosine , and

then performs the matrix multiplication

for nonzero terms.


DTEIT 19/8/

CG-6284

122

ALGORITHM
MULTIPLY-IN-ROTATION(A, H):- Routine to postmultiply the transformation matrix by a rotation
ARGUMENTS A angle of counterclockwise
rotation
H a 3*2 transformation matrix
LOCAL
S,C the sine and cosine values
I for stepping through the array
TEMP temporary storage of the
first column

DTEIT 19/8/

CG-6284

123

ALGORITHM
BEGIN
C<--COS(A);
S<--SIN(A);
FOR I=1 TO 3 DO
BEGIN

DTEIT 19/8/

CG-6284

124

ALGORITHM
TEMP<--H[I,1]*C-H[I,2]*S;
H[I,2]<--H[I,1]*S+H[I,2]*C;
H[I,1]<--TEMP;
END;
RETURN;
END;
DTEIT 19/8/

CG-6284

125

ALGORITHM
DO-TRANSFORMATION(X,Y,H):- Routine to
transform a point
ARGUMENTS X,Y the coordinates of the point to
be transformed
H a 3*2 transformation matrix
LOCAL
TEMP temporary storage for the new
X value.

DTEIT 19/8/

CG-6284

126

ALGORITHM
BEGIN
TEMP <-- X*H[1,1]+Y*H[2,1]+H[3,1];
Y<-- X*H[1,2]+Y*H[2,2]+H[3,2];
X<--TEMP;
RETURN;
END;
DTEIT 19/8/

CG-6284

127

ALGORITHM
TRANSLATE (TX,TY):-User routine to set
the translation parameters
ARGUMENTS TX,TY the translation amount
GLOBAL

TRNX, TRNY storage for the


translation parameters

DTEIT 19/8/

CG-6284

128

ALGORITHM
BEGIN
TRNX <-- TX;
TRNY <-- TY;
CALL NEWFRAME;
RETURN;
END;
DTEIT 19/8/

CG-6284

129

ALGORITHM
SCALE(SX,SY):-User routine to set the
scaling parameters
ARGUMENTS SX,SY the scaling factors
GLOBAL

SCLX,SCLY storage for the

scale parameters
DTEIT 19/8/

CG-6284

130

ALGORITHM
BEGIN
SCLX<-- SX;
SCLY<--SY;
CALL NEWFRAME;
RETURN;
END;
DTEIT 19/8/

CG-6284

131

ALGORITHM
ROTATE (A):- User routine to set the rotation
angle
ARGUMENTS A the rotation angle
GLOBAL
ANGL a place to save the
rotation angle
BEGIN
ANGL<-- A;
CALL NEWFRAME;
RETURN;
END;
DTEIT 19/8/

CG-6284

132

ALGORITHM
BUILD-TRANSFORMATION:-Routine to build the
image transformation matrix
GLOBAL ANGL,SCLX,SCLY, TRNX, TRNY

the

transformation parameters
IMAGE- XFORM a 3*2 array

containing the

image transformation
DTEIT 19/8/

CG-6284

133

ALGORITHM
BEGIN
IDENTITY- MATRIX (IMAGE-XFORM)
MULTIPLY-IN-SCALE(SCLX,SCLY,
IMAGE-XFORM);
MULTIPLY-IN-SCALE
(SCLX,SCLY,IMAGE- XFORM);
DTEIT 19/8/

CG-6284

134

ALGORITHM
MULTIPLY-IN-ROTATION
(ANGL,IMAGE-XFORM);
MULTIPLY-IN-TRANSLATION
(TRNX,TRNY,IMAGE-XFORM);
RETURN;
END;
DTEIT 19/8/

CG-6284

135

ALGORITHM
MAKE-PICTURE-CURRENT:-User routine
to show the current display file
GLOBAL FREE the index of the next free
display- file cell
ERASE-FLAG indicates if frames
should be clear
BEGIN
IF ERASE-FLAG THEN
DTEIT 19/8/

CG-6284

136

ALGORITHM
BEGIN
ERASE;
ERASE-FLAG<--FALSE;
END;
BUILD-TRANSFORMATION;
IF FREE > 1 THEN INTERPRET (1,FREE-1);
DISPLAY;
FREE <-- 1;
RETURN;
END;
DTEIT 19/8/

CG-6284

137

RASTER METHODS FOR


TRANSFORMATION
Raster functions that manipulate
rectangular pixel arrays are generally
referred to as raster ops. Moving a block of
pixel from one location to another also
called a block transfer of pixel values. On a
bilevel system
DTEIT 19/8/

CG-6284

138

RASTER METHODS FOR


TRANSFORMATION
This operation is called a bitbelt (bitblock
transfer) particularly when the function is
hardware implemented. The term pixbelt is
some time used for block transfer on
multilevel system ( multiple bits per pixel ).

DTEIT 19/8/

CG-6284

139

RASTER METHODS FOR


TRANSFORMATION
Typical raster function often provided in
graphics packages are :
1. Copy - move a pixel block from one raster
area to another.
2. Read - save a pixel block in a designed
arrays.
3. Write - transfer a pixel array to a position in
the frame buffer.
DTEIT 19/8/

CG-6284

140

Pmax
Pmin
P0

Translating an object from screen position (a)


to position (b) by moving a rectangular block
of pixel value coordinate positions Pmin &
Pmax specifies the limits of the rectangular
block to be moved, & P0 is the destination
reference position.
DTEIT 19/8/

CG-6284

141

EXERCISE 3
Prove that a uniform scaling (Sx = Sy) and
a rotation from a commutative pair of
operations but that, in general, scaling and
rotation are not commutative operations.

DTEIT 19/8/

CG-6284

142

EXERCISE 3
Show that transformation matrix (5-33),
for a reflection about the line y =x, is
equivalent to a reflection relative to the x
axis followed by a counterclockwise
rotation of 90.

DTEIT 19/8/

CG-6284

143

EXERCISE 3
Show that transformation matrix (5-34) for
a reflection about the line y=-x, is
equivalent to a reflection relative to the y
axis followed by a counterclockwise
rotation of 90.

DTEIT 19/8/

CG-6284

144

EXERCISE 3
Determine the form of the transformation
matrix for a reflection about an arbitrary
line with equation y= mx+b

DTEIT 19/8/

CG-6284

145

EXERCISE 3
Determine the sequence of basic
transformations that are equivalent to
the x-direction shearing matrix(5-35).

DTEIT 19/8/

CG-6284

146

EXERCISE 3
Determine the sequence of basic
transformations that are equivalent to
the y-direction shearing matrix (5-36).

DTEIT 19/8/

CG-6284

147

Magnification of an object while keeping


its center fixed. Let the geometric center be
located at c(h,k) in figure (a). Choosing a
magnification factor s>1. We construct the
transformation by performing the following
sequence of the transformation :
DTEIT 19/8/

CG-6284

148

(1) Translate the object so that its center


coincides with the origin in figure (b), (2)
scale the object with respect to the origin in
figure (c), and (3) translate the scaled object
back to the original position in figure (d).

DTEIT 19/8/

CG-6284

149

The required transformation ss,c can be


formed by composition ss,c=t-1v.Ss,s.Tv
where v= -hi - hj. By using composition,
we can build more general scaling, rotation
and reflection transformation.For these
transformations,

DTEIT 19/8/

CG-6284

150

We shall use the following notations : (1)


ssx,sy,p -scaling with respect to a fixed
point p ;(2) r,p -rotation about a point p ;
(3) ml-reflection about a line l.

DTEIT 19/8/

CG-6284

151

2
C(h,k)
1

1
DTEIT 19/8/

2
(A)

CG-6284

x
152

(B)
DTEIT 19/8/

CG-6284

153

(C)
DTEIT 19/8/

CG-6284

154

y
4
3
2

1
1

(D)
DTEIT 19/8/

CG-6284

155

DTEIT 19/8/

CG-6284

156

TWO-DIMENSIONAL VIEWING
viewport

window

WORLD COORDINATE

DEVICE COORDINATE

A VIEWING TRANSFORMATION USING STANDARD


RECTANGLES FOR WINDOW & VIEWPORT
DTEIT 19/8/

CG-6284

157

2-D VIEWING
A world coordinate area selected for display is

called a window.

An area on a display device to which a

window is mapped is called a viewport.

DTEIT 19/8/

CG-6284

158

2-D VIEWING
#.

The mapping of a part of a world-

coordinate scene to device coordinate is


referred to as a viewing transformation.
#.

The 2-d viewing transfor-mation is

simply reffered as the window to veiwing


transformation.
DTEIT 19/8/

CG-6284

159

2-D VIEWING
ws2 Window
ws2
Viewport

Viewing
coordinate
window
ws1
Viewport

Monitor1

ws1
Window

TWO-DIMENSIONAL VIEWING
DTEIT 19/8/
CG-6284

Monitor2

160

2-D VIEWING

Any number of output devices can be open in


aparticular

application,

&

another

window-to-

viewport transformation can be performed for each


open

output

devices.This

mapping

is

called

workstation transformation.

DTEIT 19/8/

CG-6284

161

ASPECT RATIO
#. Since the viewing transformation involves
scaling, undesirable distortions may be
introduced whenever sx

sy. For example,

circles within which the window may be


displayed as ellipses and squares as
rectangles. In consdering how

DTEIT 19/8/

CG-6284

162

ASPECT RATIO
These distortions may be

avoided, the concept

of aspect ratio is needed. The aspect ratio of a


rectangulatr window or viewport is defined by
A=xmax-xmin/ymax-ymin

DTEIT 19/8/

CG-6284

163

ASPECT RATIO
If the aspect ratio aw of the window equals the
aspect ratio av of the vieport then sx=sy, and no
distortion occurs.If aw !=

av,

then distortion

occurs. If desired ,

DTEIT 19/8/

CG-6284

164

ASPECT RATIO
In this case we can describe a region within
the viewport, a subviewport, whose aspect
ratio is that of the window.

DTEIT 19/8/

CG-6284

165

ASPECT RATIO

The method for selecting a and enlarging


portions of the drawing is called windowing. The
technique for not showing that part of the drawing
which one is not interested in is called clipping.

DTEIT 19/8/

CG-6284

166

ASPECT RATIO

There is the object model and there is

the image of the object which appears on


the display. When we speak of the object,
we are actually referring to a model of the
object stored in the computer .

DTEIT 19/8/

CG-6284

167

ASPECT RATIO

The object model is said to reside in

object space. This model represent the


object using yhe physical units of length.

DTEIT 19/8/

CG-6284

168

12M

(.25, .5)
(.25, .5)

(.5, .2)

12M

IN THE OBJECT SPACE,POSITION IS MEASURED IN PHYSICAL


UNITS SUCH AS METERS. IN THE IMAGE SPACE , POSITION IS
GIVEN IN NORMALIZED SCREEN COORDINATES.

DTEIT 19/8/

CG-6284

169

ASPECT RATIO

We must have some way of covertingfrom

the object space units of measure to those of


the image space ( screen space ) . this can be
done by the scaling transformation.

DTEIT 19/8/

CG-6284

170

1/48 0 0
X

0 1/48 0
0 0 1

=
A SCALING TRANSFORMATION WILL CONVERT OBJECT
COORDINATE UNITS TO NORMALIZED SCREEN COORDINATES.

DTEIT 19/8/

CG-6284

171

ASPECT RATIO

The object is too complex to show in its


entirety or that we are particularly interested in
just a portion of it.We would like to imagine a box
about a portion of the object . we would only
display what is enclosed in the box. Such a box is
called a window.

DTEIT 19/8/

CG-6284

172

WINDOW

OBJECT SPACE

IMAGE SPACE

A WINDOW TO VIEW ONLY PART OF AN OBJECT.


DTEIT 19/8/

CG-6284

173

ASPECT RATIO

We would like to imagine a box on the

screen and have the image confined to that


box.Such a box in the screen space is called
a viewport.

DTEIT 19/8/

CG-6284

174

VIEWPORT

A VIEW PORT TO DEFINE THE PART OF THE


SCREEN TO BE USED.

DTEIT 19/8/

CG-6284

175

ASPECT RATIO

When the window is changed, we see a

different part of the object shown at the


same position on the display.

DTEIT 19/8/

CG-6284

176

DIFFERENT WINDOWS, SAME VEIWPORTS


DTEIT 19/8/
CG-6284
177

ASPECT RATIO

If we change the viewport , we see the

same part of the object drawn at a different


place on the display.

DTEIT 19/8/

CG-6284

178

The overall transformation which performs


these three steps we shall call the viewing
transformation.

TRANSLATE

SCALE

TRANSLATE

VIEWING TRANSFORMATION
DTEIT 19/8/

CG-6284

179

In general,the viewing transformation is

-WXL -WYL

DTEIT 19/8/

(VXH-VXL) /
(WXH-WXL)

0
0

0
(VYH-VYL) /
(WYH-WHL)

CG-6284

0
0

VXL VYL 1

180

VXH-VXL)/
(WXH-WXL)

VXL-WXL(VXH-VXL)/
(WXH-WXL)

DTEIT 19/8/

(VYH-VYL)/
(WYH-WYL)

VYL-WYL(VYH-VYL)/
(WYH-WYL)

CG-6284

181

CLIPPING

Clipping tells us how to cut off the lines

which are outside the window so that only


the lines within the window are displayed.If
it is inside, the line is displayed; if it is
outside, nothing is drawn.

DTEIT 19/8/

CG-6284

182

CLIPPING

If it crosses the boundry we must


determine the point of intersection and draw
only the portion which lies inside.

19/8/
DTEIT

BEFORE

AFTER
CG-6284

183

CLIPPING

CLIP LEFT

CLIP RIGHT

CLIP BOTTOM

DTEIT 19/8/

CG-6284

CLIP TOP

184

ALGORITHM SET-VIEW PORT(XL,XH,YL,YH)


#. User routine for specifying the viewport
Arguments
XL,XH
the left and right viewport boundaries
YL,YH
the bottom and up viewport boundaries
Global
VXL-HOLD,VXH-HOLD,VYL-HOLD,VYH-HOLD
storage for the viewport boundaries
DTEIT
19/8/

CG-6284

185

ALGORITHM SET-VIEW PORT(XL,XH,YL,YH)


BEGIN
IF XL>=XH OR YL>=YH THEN RETURN ERROR `BAD
VIEW PORT`;
VXL-HOLD <--- XL;
VXH-HOLD <--- XH;
VYL-HOLD <--- YL;
VYH-HOLD<--- YH;
RETURN;
END;

DTEIT
19/8/

CG-6284

186

ALGORITHM SET WINDOW PORT(XL,XH,YL,YH)


# User routine for specifying the window
Arguments
XL,XH
YL,YH

the left and right window boundaries


the bottom and up window boundaries

Global
WXL-HOLD,WXH-HOLD, WYL-HOLD,WYH-HOLD

storage for the window boundaries


DTEIT
19/8/

CG-6284

187

ALGORITHM SET WINDOW PORT(XL,XH,YL,YH)


BEGIN
IF XL>= XH OR YL>= YH THEN RETURN
ERROR`BAD WINDOW`;
WXL-HOLD <--- XL;
WXH-HOLD <--- XH;
WYL-HOLD <--- YL;
WYH-HOLD <--- YH;
RETURN;
END;
DTEIT
19/8/

CG-6284

188

THE CLIPPING PROCESS


CLIPPING
Clip left

Clip right

Clip bottom

Clip top

Viewing
transform
DTEIT 19/8/

CG-6284

189

ALOGRITHM CLIP-LEFT (OP, X,Y)

Routine for clipping against the left boundary


Arguments
OP,X ,Y a display file in instruction
Global
WXL window left boundary
XS,YS arrays containing the last point
drawn
NEEDFIRST array of indicators for saving the
first command
DTEIT
19/8/

CG-6284

190

ALOGRITHM CLIP-LEFT (OP, X,Y)


FIRSTOP, FIRSTX FIRSTY arrays for saving the
first command
CLOSING indicates the stage in polygon
BEGIN
IF PFLAG ANG NEEDFIRST(1) THEN
BEGIN
FIRSTOP (1)<--OP;
FIRSTX(1)<--X;
FIRSTY(1)<--Y;
DTEIT
19/8/

CG-6284

191

ALOGRITHM CLIP-LEFT (OP, X,Y)


NEEDFIRST(1)<-- FALSE;
END
Case of drawing from outside in
ELSE IF X>= WXL AND XS (1) < WXL THEN
CLIP-RIGHT (1,WXL,(Y-YS(1))*(WXL-X)/(XXS(1)+Y)
Case of drawing from inside out
ELSE IF X<= WXL AND XS (1) > WXL THEN
IF OP>0 THEN
DTEIT
19/8/

CG-6284

192

ALOGRITHM CLIP-LEFT (OP, X,Y)


CLIP-RIGHT (OP,WXL,(Y-YS(1))*(WXL-X)/(XXS(1))+Y) ELSE
CLIP-RIGHT (1,WXL,(Y-YS(1))*(WXL-X)/(XXS(1)+Y);
Remember point to serve as one of the end points
of next line segments
XS(1)<--X;
YS(1)<--Y;
DTEIT
19/8/

CG-6284

193

ALOGRITHM CLIP-LEFT (OP, X,Y)

Case of point inside


IF X>=WXL AND CLOSING <> 1
THEN CLIP-RIGHT(OP, X,Y);
RETURN;
END;

DTEIT 19/8/

CG-6284

194

ALOGRITHM CLIP-RIGHT (OP, X,Y)


#. Routine for clipping against the right boundary
Arguments
OP,X ,Y a display file in instruction
Global
WXL window right boundary
XS,YS arrays containing the last point
drawn
NEEDFIRST array of indicators for saving the
first command
DTEIT 19/8/

CG-6284

195

ALOGRITHM CLIP-RIGHT (OP, X,Y)


FIRSTOP,FIRSTX,FIRSTY arrays for saving the
first command
CLOSING indicates the stage in polygon
BEGIN
IF PFLAG AND NEEDFIRST(2) THEN
BEGIN
FIRSTOP(2)<-- OP;
FIRSTX(2)<-- X;
FIRSTY(2)<--Y;
DTEIT
19/8/

CG-6284

196

ALOGRITHM CLIP-RIGHT (OP, X,Y)


NEEDFIRST(2)<-- FALSE;
END
ELSE IF X<= WXH AND XS (2) > WXH THEN
CLIP-BOTTOM (1,WXH,(Y-YS(2))*(WXH-X)/(XXS(2)+Y)
ELSE IF X>= WXH AND XS (2) < WXH THEN
IF OP>0 THEN
CLIP-BOTTOM (OP, WXH, (Y-YS(2))*(WXH-X)/(XXS(2))+Y)

DTEIT 19/8/

CG-6284

197

ALOGRITHM CLIP-RIGHT (OP, X,Y)


ELSE
CLIP-BOTTOM(1,WXH,(Y-YS(2))*(WXH-X)/(XXS(2)) +Y);
XS(2)<--X;
TS(2)<--Y;
IF X<=WSH AND CLOSING <> 2 THEN CLIPBOTTOM (OP, X,Y);
RETURN;
END;
DTEIT 19/8/

CG-6284

198

ALOGRITHM CLIP-BOTTOM (OP, X,Y)


#. Routine for clipping against the lower boundary
Arguments
OP,X ,Y a display file in instruction
Global
WXL window lower boundary
XS,YS arrays containing the last point drawn
NEEDFIRST array of indicators for saving the first
command
DTEIT 19/8/

CG-6284

199

ALOGRITHM CLIP-BOTTOM (OP, X,Y)


FIRSTOP, FIRSTX FIRSTY arrays for saving the first
command
CLOSING indicates the stage in polygon
BEGIN
IF PFLAG ANG NEEDFIRST(3) THEN
BEGIN
FIRSTOP (3)<--OP;
FIRSTX(3)<--X;
FIRSTY(3)<--Y;

DTEIT 19/8/

CG-6284

200

ALOGRITHM CLIP-BOTTOM (OP, X,Y)


NEEDFIRST(3)<-- FALSE;
END
ELSE IF Y>= WXL AND YS (3) < WYL THEN
CLIP-TOP (1,( X-XS(3))*(WYL-Y)/(Y-YS(3))
+X,WYL)
ELSE IF Y<= WYL AND YS (3) > WYL THEN
IF OP>0 THEN
DTEIT 19/8/

CG-6284

201

ALOGRITHM CLIP-BOTTOM (OP, X,Y)


CLIP-TOP (OP,X-XS(3))*(WYL-Y)/(YYS(3)+X,WYL)
ELSE
CLIP-TOP(1,(X-XS(3))*(WYL-Y)/(Y-YS(3))
+X,WYL);
XS(3)<--X;
YS(3)<--Y;
DTEIT 19/8/

CG-6284

202

ALOGRITHM CLIP-BOTTOM (OP, X,Y)


IF Y>=WYL AND CLOSING <> 3
THEN CLIP-TOP (OP, X,Y);
RETURN;
END;
DTEIT 19/8/

CG-6284

203

ALOGRITHM CLIP-TOP (OP, X,Y)


#. Routine for clipping against the upper boundary
Arguments
OP,X,Y a display file instruction
Global
WYH window upper boundary
XS,Ys array containing the last point drawn
NEEDFIRST array of indicators for saving the
first command

DTEIT 19/8/

CG-6284

204

ALOGRITHM CLIP-TOP (OP, X,Y)


FIRSTOP,FIRSTX,FIRSTY arrays for saving the first
command
CLOSING indicates the stage in polygon
BEGIN
IF PFLAG AND NEEDFIRST(4) THEN
BEGIN
FIRSTOP(4)<-- OP;
FIRSTX(4)<-- X;
FIRSTY(4) <-- Y;
NEEDFIRST(4)<-- FALSE;
END
DTEIT
19/8/

CG-6284

205

ALOGRITHM CLIP-TOP (OP, X,Y)


ELSE IF Y <= WYH AND YS(4)> WYH THEN
SAVE-CLLIPED- POINT (1,(X-XS(4))*(WYH-Y)/(Y-YS(4))
+X,WYH)
ELSE IF Y>=WYH AND YS (4)<WYHTHEN
IF OP >0 THEN
SAVE-CLLIPED-POINT( OP,(X-XS(4))*(WYH-Y)/ (YYS (4))+X,WYH)
ELSE

DTEIT
19/8/

CG-6284

206

ALOGRITHM CLIP-TOP (OP, X,Y)


XS(4) <-- X;
YS(4) <-- Y;
IF Y<= WYH AND CLOSING <> 4
THEN SAVE-CLIPPED-POINT (OP, X,
Y);
RETURN;
END;
DTEIT 19/8/

CG-6284

207

MULTIPLE WINDOWING
Some systems allow the use of multiple
windowing:

A first image is created by one or more


window transformations on the object.

Windows are applied to this first image to


create a second image.

Further windowing transformations may be


done until the desired picture is created.
DTEIT 19/8/

CG-6284

208

MULTIPLE WINDOWING
ADVANTAGES:
Every application of a window
transformation allows the user to slice up a
portion of the picture and reposition it on
the screen.

Thus multiple windowing gives the user


freedom to rearrange components of the
picture.
DTEIT 19/8/

CG-6284

209

WINDOW

VIEW PORT

YWMAX

YVMAX

YWMIN

YVMIN
XWMIN

XWMAX

WORLD COORDINATES

XVMIN

XVMIN

DEVICE COORDINATES

A VIEWING TRANSFORMATION USING STANDARD


RECTANGLES FOR THE WINDOW & VIEWPORT

DTEIT
19/8/

CG-6284

210

MC

CONSTRUCT WORLDCOORDINATE SCENE


USING MODELINGCOORDINATE
TRANSFORMATIONS

WC

CONVERT
WORLDCOORDINATES
TO VIEWING
COORDINATES
VC

DC

MAP
NORMALIZED
VIEWPORT TO
DEVICE
COORDINATES

NVC

MAP VIEWING
COORDINATES TO
NORMALIZED VIEWING
COORDINATES USING
WINDOW-VIEWPORT
SPECIFICATIONS

TWO DIMENSIONAL VIEWING TRANSFORMATION


DTEIT
19/8/

CG-6284

211

y WORLD
WINDOW

1
VIEWPOINT

y0

x0

x WORLD

WORLD COORDINATES

NORMALIZIED DEVICE
COORDINATES

SETTING UP A ROTATED WORLD WINDOW IN VIEWING COORDINATES &


THE CORRESPONDING NORMALIZED - COORDINATE VIEWPORT.

DTEIT 19/8/

CG-6284

212

y WORLD

y WORLD
y

y0

y VIEW

VI
EW

x VIEW
x0

TRANSLATE THE
VIEWING ORIGIN TO
THE WORLD ORIGIN.

DTEIT 19/8/

x WORLD

x WORLD
VI
EW

ROTATE TO ALIGN THE


AXES OF THE TWO
SYSTEMS

CG-6284

213

YWMAX
YVMAX
(xw, yw)

(xv, yv)

YWMIN

YVMIN
XWMIN

XWMAX

XVMIN

XVMIN

A POINT AT POSITION (xw, yw) IN A DESIGNATED WINDOW


IS MAPPED TO VIEWPORT COORDINATES (xv, yv) SO THAT
RELATIVE POSITIONS IN THE TWO AREAS ARE THE SAME.

DTEIT 19/8/

CG-6284

214

WINDOW TO VIEWPORT
COORDINATE TRANSFORMATION
A point at position (xw,yw) in the window
is mapped into position (xv,yv)in the
associated viewport. To maintain the same
relative placement in the viewport as in the
window,we require that:

DTEIT
19/8/

CG-6284

215

WINDOW TO VIEWPORT
COORDINATE TRANSFORMATION
xv-xvmin
xw-xwmin
xvmax -xvmin = xwmax -xwmin
yv-yvmin
yw-ywmin
=
yvmax -yvmin
ywmax -ywmin
xv = xvmin - ( xw - xwmin)sx
yv = yvmin + ( yw - ywmin)sy
DTEIT
19/8/

CG-6284

216

WINDOW TO VIEWPORT
COORDINATE TRANSFORMATION
xvmax -xvmin

sx =
xwmax -xwmin
yvmax -yvmin

sy = yw -yw
max
min
THE CONVERSION IS PERFORMED WITH THE
FOLLOWING SEQUENCE OF TRANSFORMATIONS:
DTEIT
19/8/

CG-6284

217

WINDOW TO VIEWPORT
COORDINATE TRANSFORMATION

Perform a scaling trans-formation using

a fixed point position of (xwmin, ywmin) that


scales the window area to the size of the
viewport.

Translate the scale window area to the

position of the viewport.


DTEIT
19/8/

CG-6284

218

CLIPPING

An algorithm for three dimensional


clipping identifies and saves all surface
segments within the view volume for
display on the output device.

All parts of the objects that are outside


the view volume are discarded.Clipping in
three dimensions can be accomplished
using extensions of two-dimensional
clipping methods.
DTEIT 19/8/

CG-6284

219

CLIPPING OPERATIONS
In the following sections, we consider
algorithms for clipping the
following
primitive types :
point clipping.
Line clipping (straight - line
segments).
Area clipping (polygons)
Curve clipping.
Text clipping.
DTEIT 19/8/

CG-6284

220

POINT CLIPPING
Assuming that the clip window is a
rectangle in standard position, we save a
point p = (x,y) for display if the following
inequalities are satisfied:

xwmin <= x <= xwmax


ywmin <= y <= ywmax

DTEIT
19/8/

CG-6284

221

LINE CLLIPING
A line clipping procedure

involves

sevaral parts.

First, we can test a given line segment to

determine whether it lies completely inside


the clipping window. If it does not,

DTEIT
19/8/

CG-6284

222

LINE CLLIPING

Secondly, we try to Determine whether it

is completely outside the window .

finally, if we cannot identify a line as

completely inside or completely outside, we


must perform intersection calculation with
one or more clipping boundries.
DTEIT
19/8/

CG-6284

223

LINE CLLIPING

We process line through the `inside-

outside `test by cheching the line endpoints.


#

A line with with both endpoints inside


all clipping boundaries is saved.

A line with both endpoints outside any


one of the clip boundaries is clipped.

DTEIT
19/8/

CG-6284

224

WINDOW

BEFORE CLIPPING

WINDOW

AFTER CLIPPING

LINE CLIPPING AGAINST A RECTANGULAR CLIP WINDOW


DTEIT 19/8/

CG-6284

225

COHEN-SUTHERLAND CLIPPING

This is the one of the oldest & popular

line-clipping procedure.

It is the method that can be used to test

lines for total clipping is to perform the logical


and operation with both region codes. If the
result is not 0000, the line is completely
outside the clipping region.
DTEIT
19/8/

CG-6284

226

LINE CLLIPING

Those lines that cannot be identified as

completely inside or outside a clipping


window by these tests

are checked for

intersection with the windows boundries.


DTEIT
19/8/

CG-6284

227

LINE CLLIPING
#

The clipping process for a line is started


by comparing an outside endpoint to a
clipping boundary to determine how much
of the line can be discarded. Then the
remaining part of the line is checked against
the other boundaries and continue untill
either the line is totally discarded or a
section is found inside the window.

DTEIT
19/8/

CG-6284

228

1001

1000

1010

0001

0000

0010

0101

WINDOW

0100

0110

BINARY REGION CODES ASSINGNED TO LINE


ENDPOINTS ACCORDING TO RELATIVE POSITION WITH
RESPECT TO THE CLIPPING RECTANGLE.

DTEIT 19/8/

CG-6284

229

P2
WINDOW
P2`

P2``
P1`

P3
P3`

P4

P1

LINE EXTENDED FROM ONE


COORDINATE REGION TO ANOTHER
MAY PASS TROUGH
THE CLIP WINDOW, OR THEY MAY
INTERSECT CLIPPING BOUNDARIES
WITHOUT ENTERING THE WINDOW.

DTEIT 19/8/

CG-6284

230

COHEN-SUTHERLAND
LINE CLIPPING ALGORITHM

Procedure clipcohsuth(winMin, winMax :


dcPt2; n : integer; pts : wcPts2);
type
Boundary = (left, right, bottom, top);
Code=array[Boundary] of boolean;
var
I : integer;
function encodes {pt : wcPt2} : Code;
var c : Code;
DTEIT
CG-6284
19/8/

231

COHEN-SUTHERLAND
LINE CLIPPING ALGORITHM

begin
if pt.x < winMin.x then c[Left]
:= true else c[Left] := false ;
if pt.x > winMax.x then c[Right]
:= true else c[Right] := false ;
if pt.y < winMin.y then c[Bottom]
:= true else c[Bottom] := false;
if pt.y > winMax.y then c[Top]
:= true else c[Top] :=false ;
end ;
{ encode }
DTEIT
CG-6284
19/8/

232

COHEN-SUTHERLAND
LINE CLIPPING ALGORITHM

function accept { c1, c2 : code } : boolean ;


var k : Boundary;
begin
accept := true ;
for k := Left to Top do
if { c1[k] } and c2[k] } then accept :=true
end;
function reject { c1,c2 :code } :boolean;
var k : Boundary;
DTEIT
CG-6284
233
19/8/

COHEN-SUTHERLAND
LINE CLIPPING ALGORITHM

begin
reject := false ;
for k := Left to Top do
if { c1[k] and c2[k] } then reject := true
end;
function ptInside { c: Code } : boolean ;
begin
if { c[Left] } or { c[Right] } or
{c[Top]} or { c[Bottom]} then
DTEIT
CG-6284
19/8/

234

COHEN-SUTHERLAND
LINE CLIPPING ALGORITHM

ptInside := false else ptInside := true;


end;
procedure swapPts (var p1, p2 : wcPt2);
var tmp : wcPt2;
begin
tmp := p1 ; p1 :=p2 ; p2 := tmp;
end;
procedure swapCodes (var c1, c2 : Code );
var tmp : Code ;
DTEIT
CG-6284
19/8/

235

COHEN-SUTHERLAND
LINE CLIPPING ALGORITHM

begin
tmp := c1; c1 :=c2; c2 :=tmp;
end;
procedure clipLine (p1,p2 : wcPt2);
var code1, code2 : code ;
done, draw : boolean;
m: real;
begin {clipLine }
done := false;
DTEIT
CG-6284
19/8/

236

COHEN-SUTHERLAND
LINE CLIPPING ALGORITHM

draw := false ;
while not done do
begin
code1 := encode (p1);
code2 := encode (p1);
if accept (code1, code2 ) then
begin
done := true ;
draw := true
DTEIT
CG-6284
19/8/end

237

COHEN-SUTHERLAND
LINE CLIPPING ALGORITHM

else
if reject (code1, code2)then done:=true
else
begin
(insure that p1 is outside window)
if ptInside (code1) then
begin
swapPts (p1,p2);
DTEIT
19/8/

CG-6284

238

COHEN-SUTHERLAND
LINE CLIPPING ALGORITHM

swapCodes ( code1 , code2 );


end ;
m : = ( p2.y - p1.y) / (p2.x -p1.x );
if codel [ Left ] then begin
p1.y : = p1.y + ( winMin .x - p1.x ) * m ;
p1.x : = winMin.x
end { crosses Left }
else
DTEIT
19/8/

CG-6284

239

COHEN-SUTHERLAND
LINE CLIPPING ALGORITHM

if codel [ Right ] then begin


p1.y := p1.y + (winMax .x - p1.x ) * m;
p1.x := winMax.x
end { crosses Right }
else
if codel [ Bottom ] then begin
DTEIT
19/8/

CG-6284

240

COHEN-SUTHERLAND
LINE CLIPPING ALGORITHM

p1.x := p1.x + ( winMin.y - p1.y ) / m ;


p1.y := winMin.y
end { crosses Bottom }
else
if codel [ Top ] then begin
p1.x := p1.x + ( winMax.y - p1.y ) / m ;
p1.y := winMax.y
end { crosses Top }

DTEIT
19/8/

CG-6284

241

COHEN-SUTHERLAND
LINE CLIPPING ALGORITHM

end
end;
if draw then
{ draw line from p1 to p2 }
lineDDA (round( p1.x), round(p1.y),
round (p2.x) , round (p2.y))
end; { clipLine }
DTEIT
19/8/

CG-6284

242

COHEN-SUTHERLAND
LINE CLIPPING ALGORITHM

begin
for i:=1to n-1 do clipLine (pts[i] ,pts[I+1]);
clipLine ( pts [n] , pts [1] );
end; { clipCohSuth }

DTEIT 19/8/

CG-6284

243

POLYGON CLIPPING

To clip a polygon we need to modify the

line-clipping procedure

A polygon boundary processed with a

line clipper may be displayed as series of


unconected line segments, depending on the
orientation of the polygon to the clip
window.
DTEIT 19/8/

CG-6284

244

POLYGON CLIPPING
For polygon clipping , we require an
algorithm that will generate one or more
closed areas that are then scan converted for
the appropriate atrea fill. The output of a
polygon clipper should be a sequence of
vertices that defines the clipped polygon
boundries.

DTEIT 19/8/

CG-6284

245

POLYGON CLIPPING

BEFORE CLIPPING

AFTER CLIPPING

DISPLAY OF A POLYGON PROCESSED


BY A LINE CLIPPING ALGORITHM.
DTEIT
19/8/

CG-6284

246

POLYGON CLIPPING

BEFORE
CLIPPING

AFTER
CLIPPING

DISPLAY OF CORRECTLY CLIPPIED POLYGON

DTEIT 19/8/

CG-6284

247

VECTOR METHOD FOR


SPLITTING CONCAVE POLYGONS
E5

3
2
E4

E6

1
E1
0

E2

E3
2

SPLITTING A CONCAVE POLYGON USING


THE VECTOR METHOD

DTEIT 19/8/

CG-6284

248

VECTOR METHOD FOR


SPLITTING CONCAVE POLYGONS

PREVIOUS FIGURE SHOWS A


CONCAVE
POLYGON WITH SIX
EDGES. EDGE VECTOR FOR THIS
POLYGON CAN BE EXPRESSED AS :
E1 = (1,0,0), E2 = (1,1,0)
E3 = ( 1,-1,0), E4 = (0,2,0)
E5 = (-3,0,0), E6 = (0,-2,0)
DTEIT
19/8/

CG-6284

249

VECTOR METHOD FOR


SPLITTING CONCAVE POLYGONS
#

WHERE THE COMPONENT IS 0,


SINCE ALL EDGES ARE IN THE X Y
PLANE .THE CROSS PRODUCT Ei x Ej
FOR TWO SUCCESSIVE EDGE
VECTORS IS A VECTOR
PERPENDICULAR TO THE XY PLANE
E4 WITH Z COMPONENT EQUAL TO
Eix Ejy - Ejx Ejy

DTEIT 19/8/

CG-6284

250

VECTOR METHOD FOR


SPLITTING CONCAVE POLYGONS
E1 x E2 = (0,0,1), E2 x E3 = (0,0,-2)
E3 x E4 = (0,0,2), E4 x E5 = (0,0,6)
E5 x E6 = (0,0,6), E6 x E1 = (0,0,2)
# SINCE THE CROSS PRODUCT E2 x E3
HAS A NEGATIVE Z COMPONENT, WE
SPLIT THE POLYGON ALONGE THE
LINE OF VECTOR E2 .
DTEIT
19/8/

CG-6284

251

VECTOR METHOD FOR


SPLITTING CONCAVE POLYGONS
The line equation for this edge has a slope
of 1 and a y intercept of -1. We then
determine the intesection of this line and the
other polygon edges to split the polygon
into two pieces. No other edge cross
products are negative, so the two new
polygons are both convex.
DTEIT
19/8/

CG-6284

252

V1
V2

V3

V4
SPLITTING A CONCAVE POLYGON USING THE ROTATIONAL METHOD.
AFTER ROTATING V3 ONTO THE X AXIS, WE FIND THAT V4 IS BELOW
THE X AXIS. SO WE SPLIT THE POLYGON ALONG THE LINE OF V2V3.

DTEIT 19/8/

CG-6284

253

CURVE CLIPPING
Areas with curve boundries can be
clipped with methods similar to line &
polygon clipping.

Curve clipping procedures will involves


nonlinear equations, and this reqiures more
processing than for objects with linear
boundries.

DTEIT
19/8/

CG-6284

254

CURVE CLIPPING

The bounding rectangle for a circle can be

used first to test for overlap with a rectangular


clip window.
#

If the bounding rectangle for the object is


compeletly inside the window, we save the
object.

DTEIT
19/8/

CG-6284

255

CURVE CLIPPING
#

If the rectangle is determined to be


compeletely outside the window, we discard the
object.

If the bounding rectangle test fails , we look


for other computation-saving approaches.

DTEIT 19/8/

CG-6284

256

CURVE CLIPPING
#

For a circle, we can use the coordinate extents


of individual quadrantes and then octants for
preliminary testing before calculating curvewindow intersection.

For an ellipse, we can test the coordinate extent

of the individual quadrants.


DTEIT 19/8/

CG-6284

257

CURVE CLIPPING

BEFORE
CLIPPING

AFTER
CLIPPING

CLIPPING OF A FILLED CIRCLE


DTEIT 19/8/

CG-6284

258

TEXT CLIPPING

There are several techniques that can be

used to provide text clipping in a graphics


package.

The technique used will depend on the

method used to generate character and


requirement of a particular application.
DTEIT
19/8/

CG-6284

259

TEXT CLIPPING
The simplest method for processing
character strings relative to a windows
boundary is to use the all-or-none stringclipping strategy.

If all of the string is inside the a clip


window we keep it. Otherise the string is
discarded.

DTEIT
19/8/

CG-6284

260

TEXT CLIPPING
#

This procedure is implemented by


considering a bounding rectangle around
the text pettern.

# The boundary position of the rectangle are


then comparedto the windows boundries,
and the string is regected if there is any
overlap. This method produces the fastest
text clipping.
DTEIT 19/8/

CG-6284

261

TEXT CLIPPING

An alternative to rejecting an entire

character string

that overlaps a window

boundary is to use the all-or-none characterstring strategy.


#

Here we only discard those charecters


that are not compeletly inside the window.

DTEIT
19/8/

CG-6284

262

TEXT CLIPPING
#

In this case the boundary limits of


individual character are compared to the
window.

# Any charectwer that either overlaps or is


outside a window boundary is clipped.
DTEIT 19/8/

CG-6284

263

TEXT CLIPPING
A final method for handling text clipping
is to clip the components of individual
charecters. We now treat characters in much
the same way that we treated lines.

DTEIT
19/8/

CG-6284

264

TEXT CLIPPING
#

If an individual character overlaps a


clip window boundary, we clip off the parts
of the character that are outside the window.

DTEIT 19/8/

CG-6284

265

TEXT CLIPPING
STRING1

STRING2
BEFORE CLIPPING

STRING2
AFTER CLIPPING

TEXT CLIPPING USING A BOUNDING RECTANGLE


ABOUT THE ENTIRE SCREEN.
DTEIT
CG-6284
266
19/8/

TEXT CLIPPING
STRING1
I
R
ST

STRING3

G2

NG1
R
ST

TRING3
STRING4

BEFORE CLIPPING

STRING4

AFTER CLIPPING

TEXT CLIPPING USING A BOUNDING RECTANGLE


ABOUT INDIVIDUAL CHARECTER.
DTEIT
CG-6284
267
19/8/

TEXT CLIPPING
STRING1

STRING1
2
G
N
I
R
T
S

BEFORE CLIPPING

ST

AFTER CLIPPING

TEXT CLIPPING PERFORMED ON THE COMPONENTS


OF INDIVIDUIAL CHARACTERS.
DTEIT 19/8/
CG-6284
268

EXTERIOR CLIPPING
We have considered only procedures for
clipping a picture to the interior of a region.
By eliminating everything outside the
clipping region. What is saved by these
procedure is inside the region.

DTEIT 19/8/

CG-6284

269

EXTERIOR CLIPPING

In some cases , we want to do the

reverse , that is we want to clip a picture to


the exterior of the specified region. The
picture parts to be saved are those that are
outside the region. This is reffered as
exterior clliping.
DTEIT
19/8/

CG-6284

270

EXTERIOR CLIPPING
#

A typical example of the application of


exterior clipping is in multiple window
system.

Exterior clipping is used also in other


application

that

requires

overlaping

pictures.
DTEIT
19/8/

CG-6284

271

EXTERIOR CLIPPING
#

Procedures for clipping objects to the


interior of concave polygon windows can
also make use of external clipping.

DTEIT 19/8/

CG-6284

272

EXTERIOR CLIPPING
A line p1 p2 that is to be clipped to the
interior of a concave window with vertices
v1 v2 v3 v4 v5. Line p1 p2 can be clipped in
two passes
#

first, p1 p2 is clipped to the interior of a


convex polygon v1 v2 v3 v4 to yield the
clipped segment p1` p2` .

DTEIT
19/8/

CG-6284

273

EXTERIOR CLIPPING
#

Second, then an external clip of p1`


p2` is performed aginst the convex polygon
v1 v5 v4 to yield the final clipped line
segment p1`` p2``.

DTEIT 19/8/

CG-6284

274

NORMALIZED VIEW
VOLUMES

At the step, a scene is constructed by


transforming object description from modeling
coordinates. Next, a view mapping converts
the world descriptions to viewing coordinates.
At the projection stage, the viewing
coordinates are transformed to projection
coordinates,which effectively converts the
view volume into a rectangular parallelepiped.
DTEIT
19/8/

CG-6284

275

NORMALIZED VIEW
VOLUMES
Modeling
coordinates

Modeling
transformation

World
Coordinates

Projection
Transformation

Projection
Coordinates

Workstation
Transformation

Device
Coordinates

Viewing
Transformation

Normalization
Transformation

Viewing
Coordinates

Normalized
Projection
Coordinates

PHIGS Transformation
DTEIT Expanded
19/8/
CG-6284 Pipeline

276

NORMALIZED VIEW
VOLUMES
Then, the parallelepiped is mapped into the
unit cube, a normalized view volume called
the normalized projection coordinate
system.The mapping to normalized
projection coordinates is accomplished by
transforming points within the rectangular
parallelepiped into a position within a
specified three-dimensional viewport,which
occupies part or all of the unit cube.
DTEIT
19/8/

CG-6284

277

NORMALIZED VIEW
VOLUMES
#

Finally, at the workstation stage,


normalized projection coordinates are
converted to device coordinates for display.
# The normalized view volume is a region
defined by the planes
x=0, x=1, y=0, y=1, z=0, z=1

DTEIT 19/8/

CG-6284

278

NORMALIZED VIEW
VOLUMES
A similar transformation sequence is used
in other graphics packages,with individual
variation depending on the system.The GL
package, for example, maps the rectangular
parallelepiped into the interior of a cube
with boundary planes at position +-1in each
coordinate direction.
DTEIT 19/8/

CG-6284

279

NORMALIZED VIEW
VOLUMES
ADVANTAGES: The normalized view volume provides a standard
shape for representing any sized view volume.

The clipping procedures are simplify and


standardized with unit clipping plans or the view
port plans,and additional clipping plans can be
specified within the the normalized space before
transforming to device coordinates.
DTEIT
19/8/

CG-6284

280

NORMALIZED VIEW
VOLUMES
The depth cueing and visiblesurface determination are simplified,
since the z axis always points toward
the viewer .

DTEIT 19/8/

CG-6284

281

NORMALIZED VIEW
VOLUMES
Mapping positions within a rectangular
view volume to a three-dimensional
rectangular viewport is accomplished with a
combination of scaling and translation,
similar to the operations needed for a twodimensional window-to-viewport mapping .

DTEIT 19/8/

CG-6284

282

NORMALIZED VIEW
VOLUMES

We can express the three-dimensional


transformation matrix for these operation in
the form
Dx

Kx

Dy

Ky

Dz

Kz

DTEIT
19/8/

CG-6284

(12.33)

283

NORMALIZED VIEW
VOLUMES
#

Factors Dx, Dy and Dz are the ratios of


the dimensions of viewport and regular
parallelepiped view volume in the x, y and
z directions.
Dx = (XVmax-XVmin) / (YVmax-YVmin)
Dy = (YVmax-YVmin) / (YWmax-YWmin)
Dz = (ZVmax-ZVmin) / (Zback-Zfront)
(12.34)

DTEIT
19/8/

CG-6284

284

Dimensions of the view volume and three dimensional viewport

(XWMAX,YWMAX,ZBACK)
(XWMIN,YWMIN,ZFRONT)

PARALLELPIPED
VIEW VOLUME

(xvmax,yvmax,zvmax)
X
Z
DTEIT 19/8/

(xvmin,yvmin,zvmin)
Unit cube
CG-6284

3d view point
285

VIEWPORT CLIPPING

Lines and polygon surfaces in a scene

can be clipped against the viewport


boundaries with procedures similar to those
used for two dimensions, except that objects
are now processed against clipping planes
instead of clipping edges.
DTEIT
19/8/

CG-6284

286

VIEWPORT CLIPPING

Curved surfaces are processed using the

defining equations for the surface boundary


and locating the intersections lines with the
parallelepiped planes.

DTEIT
19/8/

CG-6284

287

VIEWPORT CLIPPING

The two dimensional concept of region

codes can be extended to three dimensions


by considering positions in front and in
back of three

dimensional viewport , as

well as positions that are left ,right


,below ,or above the volume.
DTEIT
19/8/

CG-6284

288

VIEWPORT CLIPPING
For two dimensional clipping,we used a
four digit binary region code to identify the
position of a line endpoint relative to the
viewport boundaries.For three dimensional
points we need to expand the region code to
six bits.

DTEIT
19/8/

CG-6284

289

VIEWPORT CLIPPING

Each point in the description of the

scene is then assigned a six bit region code


that identifies the relative position of the
point with respect to the viewport.

DTEIT 19/8/

CG-6284

290

VIEWPORT CLIPPING
#

For a line endpoint position (x,y,z), we assign the


bit positions in the region code from right to left as :
Bit 1=1, if x<xvmin (left)
Bit 2=1,

if x>xvmax(right)

Bit 3=1,

if y<yvmin(below)

DTEIT
19/8/

CG-6284

291

VIEWPORT CLIPPING
Bit 4=1,

if y>yvmax(above)

Bit 5=1,

if z<zvmin (front)

Bit 6=1,

if z>zvmax (back)

DTEIT 19/8/

CG-6284

292

VIEWPORT CLIPPING

As in two dimensional line clipping, we

use the calculated intersection of a line with


a viewport plane to determine how much of
the line can be thrown away.
DTEIT
19/8/

CG-6284

293

VIEWPORT CLIPPING
The remaining part of the line is checked
against the other planes, and we continue
until either the line is totally discarded or a
section is found inside the volume.

DTEIT 19/8/

CG-6284

294

VIEWPORT CLIPPING
Equations for three dimensional line
segments are conveniently expressed in
parametric form. The two dimensional
parametric clipping methods of cyrus-beck
or liang-barsky can be extended to three
dimensional scenes.

For a line segment with endpoints


p1=(x1,y1,z1) and p2=(x2,y2,z2),

DTEIT 19/8/

CG-6284

295

VIEWPORT CLIPPING
# We can write the parametric line equations
as
X= x1 + (x2-x1)u, 0<=u<=1
Y= y1 + (y2-y1)u
Z= z1 + (z2-z1)u
Coordinates (x,y,z) represents any point on
the line between the two endpoints.At
u=0,we have the point p1, and u=1 puts us
at p2.
DTEIT 19/8/

CG-6284

296

VIEWPORT CLIPPING
# To find the intersection of a line with a plane of
the viewport, we substitute the coordinate value
for that plane into the appropriate parametric
expression.for instance,suppose we are testing a
line against the zvmin plane of the viewport.then
u=zvmin -z1/z2-z1

DTEIT
19/8/

CG-6284

297

VIEWPORT CLIPPING
when the calculated value for u is not in the
range from 0 to 1, the line segment does not
intersect the plane under consideration at any
point between endpoints p1 and p2.if the
calculated value for u is in the interval from 0
to 1,we calculate the intersections x and y
coordinates as
x1= x1+ (x2-x1) (zvmin-z1)/z2-z1
y1= y1+ (y2-y1)(zvmin-z1)/z2-z1
DTEIT 19/8/

CG-6284

298

CLIPPING IN HOMOGENEOUS
COORDINATES
Although we have discussed the clipping
procedures in terms of three dimensions
coordinates, PHIGS and other packages
actually represent coordinate positions in
homogeneous coordinates. This allows the
various transformations to be represented as 4
by 4matrices, which can be concatenated for
efficiency.
DTEIT 19/8/

CG-6284

299

CLIPPING IN HOMOGENEOUS
COORDINATES
#

As each coordinate position enters the


transformation pipeline, it is converted to a
homogeneous coordinate representation :
(x,y,z)

DTEIT 19/8/

(x,y,z,1)

CG-6284

300

y
Cross section of
3-dimensional
viewport

Pa2
yvmax

A
Pa1
B

yvmin

Pb2

Pb1
zvmin

zvmax

Side view of two line segments that are to be clipped against the Zvmin
plane of the viewport . For line A, eq-12-37 produces a value of u that is
outside the range from 0 to 1. For line B, eqs-12-38 produce intersection
coordinates that are outside the range from YVmin to Yvmax.

DTEIT
19/8/

CG-6284

301

The various transformation are applied and


we obtain the final homogeneous point:
xh
yh
zh
h

a11
a21
a31
a41

a12
a22
a32
a42

a13
a23
a33
a43

a14
a24
a34
a44

x
y
z
1

(12-39)

where the homogeneous parameter h may


not be 1. In fact, h can have any real value.
DTEIT
19/8/

CG-6284

302

CLIPPING IN HOMOGENEOUS
COORDINATES
Clipping then performed in homogeneous
coordinates, and clipping homogeneous positions
are converted to nonhomogeneous coordinates in
three
dimensional
normalized-projection
coordinates.

DTEIT
19/8/

CG-6284

303

CLIPPING IN HOMOGENEOUS
COORDINATES
x` = xh/h , y` = yh/h , z` = zh/h

(12-40)

# We will, of course, have a problem if the


magnitude of parameter h is very small or has
the value 0; what normally this will not

DTEIT
19/8/

CG-6284

304

CLIPPING IN HOMOGENEOUS
COORDINATES
Occur, if the transformations are carried out
properly. At the final stage in the transformation
pipeline the normalized point is transformed
to a three-dimensional device coordinate point.
The XY position is plotted on the device, and the
Z component is used for depth-information
processing.
DTEIT
CG-6284
305
19/8/

CLIPPING IN HOMOGENEOUS
COORDINATES
#

Setting up clipping procedures in


homogeneous
coordinates allows
hardware viewing implementations to
use a single procedure for both parallel
and
perspective
projection
transformation.

DTEIT 19/8/

CG-6284

306

CLIPPING IN HOMOGENEOUS
COORDINATES
#

Objects viewed with a parallel projection


could be correctly clipped in threedimensional normalized coordinates, provided
the value h=1 has not been altered by other
operations. But perspective projections, in
general, produce a homogeneous parameter
that no longer has the value 1.
DTEIT
19/8/

CG-6284

307

CLIPPING IN HOMOGENEOUS
COORDINATES
#

Converting the sheared frustum to a


rectangular parallelepiped can change the
value of the homogeneous parameter. So we
must clip in homogeneous coordinates to be
sure that the clipping is carried out
correctly. Also, rational spline

DTEIT
19/8/

CG-6284

308

CLIPPING IN HOMOGENEOUS
COORDINATES
representation are set up in homogeneous
coordinates with arbitrary values for the
homogeneous parameters including h<1.
Negative values for the homogeneous
parameter

can

also

be

generated

in

perspective projections,
DTEIT
19/8/

CG-6284

309

CLIPPING IN HOMOGENEOUS
COORDINATES
when coordinate positions are behind the
projection reference point. This can occur
in applications where we might want to
move inside of a building or other object to
view its interior.

DTEIT 19/8/

CG-6284

310

CLIPPING IN HOMOGENEOUS
COORDINATES

To determine homogeneous viewport


clipping
boundaries,
we
note
that
homogeneous- coordinates positions (x h , yh ,
zh , h) is inside the viewport if it satisfies the
inequalities.
xv min<= xh/h <=xv max
yv min <= yh/h<=yv max
zv
min < zh/h <=zv max
DTEIT
CG-6284
19/8/

(12.41)

311

CLIPPING IN HOMOGENEOUS
COORDINATES
Thus the homogeneous clipping limits are
hxv min <= xh<= hxv max
hyv min <= yh <= hyv max
hzv min <= zh <= hzv max

if h >0

hxv max <= xh <= hxv min


hyv max <= yh <= hyv min
hzv max <= zh <= hzv min

if h <0

DTEIT
19/8/

CG-6284

(12.42)

312

CLIPPING IN HOMOGENEOUS
COORDINATES
And clipping is carried out with procedures
similar to those discussed in the previous
sections. To avoid applying both sets of
inequalities in 12-42, we can simply negate
the coordinates for any point with h<0 and
use the clipping inequalities for h>0.
DTEIT 19/8/

CG-6284

313

DTEIT 19/8/

CG-6284

314

COMPUTER ANIMATION
Some typical applications of computer
generated animation are entertainment ,
advertising, scientific and engg. Studies and
training and education. We tend to think of
animation as implying object motions , the
term computer animation generally refers to
any time sequence of visual changes in a scene.

DTEIT 19/8/

CG-6284

315

COMPUTER ANIMATION
In addition to changing object postion with
translation or rotations , a computer
generated animation could display time
variations

in

object

size,

colour

transparency or surface texture.


DTEIT 19/8/

CG-6284

316

COMPUTER ANIMATION

Advertising animations often transmission

one object shape into another e.g. Transforming


a can of motor oil into an automobile engine.
Computer animation can also be generated by
changing camera parameters, such as postion,
orientation and focal length.
DTEIT 19/8/

CG-6284

317

COMPUTER ANIMATION
And we can produce computer
animations by changing lighting effects or
other parameters associated with
illumination and rendering.

DTEIT 19/8/

CG-6284

318

COMPUTER ANIMATION

Many applications of computer animation

require

realistic

representation

of

displays.An
at

the

shape

accurate
of

thunderstorm or other natural phenomenona


described with a numerical model is important
for evaluating the reliability of the model.

DTEIT 19/8/

CG-6284

319

COMPUTER ANIMATION

Also, simulators for training aircraft

pilots and heavy-equipment's operators


must produce reasonably accurate
representations of the environment.

DTEIT 19/8/

CG-6284

320

DESIGN OF ANIMATION
SEQUENCES

An animation sequence is designed with


the following steps:
Storyboard layout.
Object definitions.
Key-frame specifications.
Generation of in-between frames.

DTEIT 19/8/

CG-6284

321

DESIGN OF ANIMATION
SEQUENCES

Storyboard layout: The storyboard is an outline of the action.


It defines the sequence as a set of basic events
that are to take place. Depending on the type
of the animation to be produced, the
storyboard could consists of a set of rough
sketches or it could be the list of the basic
ideas for the motion.
DTEIT 19/8/

CG-6284

322

DESIGN OF ANIMATION
SEQUENCES
Object definitions: An object definition is given for each
participant in the action. Objects can be
defined in terms of basic shapes, Such as
polygons.The associated movements for
each object are specified along with the
shape.
DTEIT 19/8/

CG-6284

323

DESIGN OF ANIMATION
SEQUENCES
Key frame specifications:A key frame is a detailed drawing of
the scene at a certain time in the
animations sequence. Within each
key frame, each object is positioned
according to the time for that frame.
DTEIT 19/8/

CG-6284

324

DESIGN OF ANIMATION
SEQUENCES
Key frame specifications: Some key frames are chosen at extreme
in the action; others are spaced so that the
time interval between key frames is not too
great.More key frames are specified for
intricate motions than for simple, slowly
varing motions.
DTEIT 19/8/

CG-6284

325

DESIGN OF ANIMATION
SEQUENCES
Generation of in-between frames:In-between are the intermediate frames
between the key frames. The number of inbetweens needed is determined by the
media to be used to display the animation.

DTEIT 19/8/

CG-6284

326

DESIGN OF ANIMATION
SEQUENCES
Generation of in-between frames: Film requires 24 frames per second, and
graphics terminals are refreshed at the rate
of 30to 60 frames per second. Depending
on the speed specified for the motion, some
key frames can be duplicated.

DTEIT 19/8/

CG-6284

327

DESIGN OF ANIMATION
SEQUENCES
Generation of in-between frames:

For a 1- minute film sequence with no


duplication, we would need 1440
frames.
If the motion is not too complicated, we
could space the key frame a little farther
apart.

DTEIT 19/8/

CG-6284

328

GENERAL COMPUTER ANIMATION FUNCTIONS


Some steps in the development of an
animation sequence are well suited to
computer solution. This include object
manipulation and rendering, camera motions,
and the generations of in-between. Animation
packages, such as Wavefront, for example,
provide special functions for designing the
animation and processing individual objects
DTEIT 19/8/

CG-6284

329

GENERAL COMPUTER ANIMATION FUNCTIONS


One function available in animation
packages is provided to store an manage the
object database.Another typical function
simulates camera movements.Standard
motions are zooming, panning, and tilting.
Finally, given the specifications for the key
frames, the in-betweens can be
automatically generated.
DTEIT 19/8/

CG-6284

330

RASTER ANIMATIONS
On raster systems, we can generate realtime animation in limited applications using
raster operations.To rotate a block of pixels,
we need to determine the percent of area
coverage for those pixels that overlap the
rotated block.

DTEIT 19/8/

CG-6284

331

RASTER ANIMATIONS
We can also animate objects along twodimensional motion paths using the colortable transformations. Here we predefine
the object at successive positions along the
motion path, and set the successive blocks
of pixel values to color-table entries.

DTEIT 19/8/

CG-6284

332

COMPUTER-ANIMATION
LANGUAGES
Design and control of animation
sequences are handled with a set of
animation routines. A general purpose
language, such as C, LISP, PASCAL, or
FORTRAN is often used to program the
animation functions, but several specialized
animation languages have been developed.
DTEIT 19/8/

CG-6284

333

COMPUTER-ANIMATION
LANGUAGES
Animation functions include a graphics
editor, a key frame generator, an inbetween generator and standard
graphics routines.
The graphics editor allows us to design
and modify objects shapes, using spline
surfaces, constructive solid-geometry
methods.

DTEIT 19/8/

CG-6284

334

COMPUTER-ANIMATION
LANGUAGES

A typical task in an animation


specification is scene description. This
includes the positioning of objects and light
sources,
defining
the
photometric
parameters camera parameters

DTEIT 19/8/

CG-6284

335

ANIMATOR
Definition:
Animator defines the motion of
the models,cameras, and lighting
according to storyboards and
experience.
DTEIT 19/8/

CG-6284

336

ANIMATOR
The animator must:
Understand the structure and
intricacies of the model.
Be familiar with the principles
and practice of photography,
lighting, and film direction.
DTEIT 19/8/

CG-6284

337

ANIMATOR
The animator must:
Have the ability to breathe life
into the scene through realistic,
fluid motion.
DTEIT 19/8/

CG-6284

338

ANIMATOR
3D Software Recommendations
Suggestions for the best software
packages:More interested in simpler,
designer images, a package with
more shader options and nicer
rendering may be in order.
DTEIT 19/8/

CG-6284

339

ANIMATOR
3D Software Recommendations
Artists needing a moderately
priced tool for Mac or PC 3D
illustration work should weigh
truespace2 alongside others at or
below its price point.
DTEIT 19/8/

CG-6284

340

ANIMATOR
`3D Software Recommendations
In the mid-range, LightWave is
available for several different
platforms.The moderately priced
Mac package Strata StudioPro is a
good choice.
DTEIT 19/8/

CG-6284

341

ANIMATOR
Choosing a Hardware platform:
There are three major platforms for
3D graphics, namely PC,Mac and
Unix-type workstations.

DTEIT 19/8/

CG-6284

342

ANIMATOR
Choosing a Hardware platform:
Besides shopping for a particular
manufacturer and model of system
you also should investigate the
peripherals and cards provided.
DTEIT 19/8/

CG-6284

343

ANIMATOR
Choosing a Hardware platform:
The heart of any computer is
printed circuit card called the
motherboard,
which
contains
numerous electronic components, such
as CPU which is brain of the system.
DTEIT 19/8/

CG-6284

344

ANIMATOR
Choosing a Hardware platform
Two main considerations of
processors are architecture and
speed.Chip architecture refers to
the internal design of the processor.
DTEIT 19/8/

CG-6284

345

ANIMATOR
Choosing a Hardware platform
The second consideration is
clock speed, which is basically
how fast a processor executes
instructions, it is measured in
millions of cycles per second.
DTEIT 19/8/

CG-6284

346

ANIMATOR
Choosing a Hardware platform
In addition to processor, there
are other chipsets on PC
motherboards that can affect
performance.Final consideration is
tech support.
DTEIT 19/8/

CG-6284

347

ANIMATOR
SGI/Unix
Silicon Graphics Workstations
have long been considered the
ultimate platform for creating
computer graphics.
DTEIT 19/8/

CG-6284

348

ANIMATOR
SGI/Unix
SGI Workstations hold the top
position in computer graphics due
to their speed and advanced
scaleable
3D
acceleration
hardware.
DTEIT 19/8/

CG-6284

349

ANIMATOR
SGI/Unix
There are also high-powered Unix
workstations as well, including the
Sun SparcStation, DEC alpha, IBM
RS6000,
and
others.

DTEIT 19/8/

CG-6284

350

ANIMATOR
PC:
The PC is the overwhelming
winner in the desktop computer wars.
They are relatively inexpensive,
going for less than $1,000 for a
decent P5/133 to about $6,000.
DTEIT 19/8/

CG-6284

351

ANIMATOR
Macintosh:
The Macintosh has been a
substantial rise in computing power,e
specially since Apple finally started
licensing its architecture and OS to
third parities.
DTEIT 19/8/

CG-6284

352

ANIMATOR
Platform Recommendations:
The right platform to buy is one
that runs the software you want.

DTEIT 19/8/

CG-6284

353

ANIMATOR
Platform Recommendations:
The PC is most popular platform,
and the intense competition among
manufacturers keeps driving the
price/performance ratios at a
breakneck pace.
DTEIT 19/8/

CG-6284

354

ANIMATOR
Choosing Peripherals:
Every computer system needs
some peripheral devices to be truly
usable, be it a monitor, hard drive
or other mass storage device,
printer or modem.
DTEIT 19/8/

CG-6284

355

ANIMATOR
Choosing Peripherals:
Peripherals, such as cartridge hard
drives and modems are available in
either
internal
or
external
configurations, means that you either
install them inside your CPU or in
their own enclosure.
DTEIT 19/8/

CG-6284

356

ANIMATOR
Choosing Peripherals:

Storage: The first law of


computing states that files expand
to overflow your storage capacity.
An example is desktop video.
DTEIT 19/8/

CG-6284

357

ANIMATOR
Choosing Peripherals:
Hard Drive Basics: Hard drives
were a bulky, expensive rarity, and
practically unheard of for desktop
systems.
DTEIT 19/8/

CG-6284

358

ANIMATOR
Choosing Peripherals:
Hard Drive Basics: Are sealed
units containing a motor that spins a set
of metal disks called magnetic
platters.A read/write head, moves back
and forth reading and writing data with
a set of electromagnetic pulses.
DTEIT 19/8/

CG-6284

359

ANIMATOR
Choosing Peripherals:
Hard Drive Basics: There are five
terms that will gauge drive performance:
Seek Time:The maximum time it
takes to move the read/write head to a
specific location on the disk.
DTEIT 19/8/

CG-6284

360

ANIMATOR
Choosing Peripherals
Track-to-track seek time: The time it
takes to move the read/write head from
one track to another.
Data transfer rate: The maximum rate
at which information is delivered from
the drive to computer.
DTEIT 19/8/

CG-6284

361

ANIMATOR
Choosing Peripherals

Revolution Per Minute:This is


related to the data transfer rate,because
the faster the drive spins the faster the
data transferred.
Interface: The interface on the drive
must match the one in the system.
DTEIT 19/8/

CG-6284

362

ANIMATOR
Choosing Peripherals
Cartridge: Is a storage system that
uses removable media to store data.The
cartridge have magnetic platters in
them just like regular hard drive.

DTEIT 19/8/

CG-6284

363

ANIMATOR
Choosing Peripherals
Optical Media: Magneto-Optical
drives are another form of cartridgebased
storage
that
offered
comparatively
high
storage
capabilities.
DTEIT 19/8/

CG-6284

364

ANIMATOR
Choosing Peripherals

Tape Media: There are several different

types of backup formats and systems


available, including Colorado, Travan,QIC,
DLT, and DAT.The main considerations for
selecting one system over another are
capacity and cost.
DTEIT 19/8/

CG-6284

365

ANIMATOR
Choosing Peripherals
Video display Cards: The video
display card is responsible for
converting the text and graphics data in
the computer into a form that the
computer monitor can display.
DTEIT 19/8/

CG-6284

366

ANIMATOR
Choosing Peripherals
Video display Cards:
Video card Recommendation: Choice of
graphics card depend on motherboard,
because you will want to use the fastest bus
available
DTEIT 19/8/

CG-6284

367

ANIMATOR
Choosing Peripherals
Display: Computer display is the
most overlooked component in the
system.For 3D and graphic arts, a 15
monitor should be considered minimum
size, with 17 or larger desirable.
DTEIT 19/8/

CG-6284

368

ANIMATOR
Choosing Peripherals

Input Devices: Input devices are:

Trackball.
Flying Mice.
Spaceballs.
Dial boxes.
Graphics tablets: One of them are Pressuresensitive tablets.
DTEIT 19/8/

CG-6284

369

ANIMATOR

Input Devices:

Scanners: 1.Document Scanner


2.Slide Scanner.
Cameras.
Digitizers.

DTEIT 19/8/

CG-6284

370

ANIMATOR
Animation basics: Animation is
modifying any kind of object,
light, material or camera by
moving or changing it overtime.

DTEIT 19/8/

CG-6284

371

ANIMATOR
Animation basics
Frame Rates:The speed at which
the images are displayed is called
the frame rate and is measured in
frames per second.
DTEIT 19/8/

CG-6284

372

ANIMATOR
Animation basics
Keyframing: To control animation
most programs use a method called
keyframing, in which you pose
your objects in key positions at
specific frames.
DTEIT 19/8/

CG-6284

373

ANIMATOR
Animation basics
Motion Paths: A useful capability
in 3D programs is the ability to work
directly with the motion path of an
object, which is a graphical
representation of its movement.
DTEIT 19/8/

CG-6284

374

ANIMATOR
Animation basics

Pivot Points and axes: In


animation an object may be
transformed around one of several
axes or points of rotation or pivot
points.
DTEIT 19/8/

CG-6284

375

ANIMATOR
Animation basics

Preview: In the animation


process,you will want to see a
representation of how things are
moving,there will be some preview
mode that will display a simplified
version of the scene in real time.
DTEIT 19/8/

CG-6284

376

ANIMATOR
Animation basics
Links : A link is a connection
between two objects so that
animation affecting one also
influences the other.
DTEIT 19/8/

CG-6284

377

ANIMATOR
Animation basics
One object is called the parent
and movement applied to it is
transferred to the second is called
child.
DTEIT 19/8/

CG-6284

378

ANIMATOR
Animation basics
Chains: A chain is a series of
linked objects,using the same
parent and child relationship,but
extending
it
by
additional
generations to grandchild and so.
DTEIT 19/8/

CG-6284

379

ANIMATOR
Animation basics
nulls:Nulls or dummy objects
are used as invisible components
chain or as reference points for
establish remote axes for rotation.
DTEIT 19/8/

CG-6284

380

ANIMATOR
Animation basics

Forward Kinematics: Forward


kinematics is the default method of
animating linked objects, in which the
movement of the parent object affects
all the offspring on down the chain.
DTEIT 19/8/

CG-6284

381

ANIMATOR
Animation basics
Inverse Kinematics: Is a method
of controlling linked objects by
moving the end of the chain and
having the rest of it conform.
DTEIT 19/8/

CG-6284

382

ANIMATOR
Animation basics

Bones Deformation: Is the


technique of animating an object
by defining and animating an
internal skeleton that automatically
deforms the surrounding mesh.
DTEIT 19/8/

CG-6284

383

ANIMATOR
Animation basics
Morphing: Animation is a
technique that allows smooth
changes to occur to an objects shape
by defining beginning, end and
possibly intermediate forms as target.
DTEIT 19/8/

CG-6284

384

ANIMATOR
Animation basics
Deformation Grids:Space Wraps
are a means of defining an area in
3D space that has an automatic
effect on objects passing through
its influence.
DTEIT 19/8/

CG-6284

385

ANIMATOR
Animation basics
Particle Systems: These are 3D
animation modules that enable you
to generate and control the
behavior of vast number of tiny
objects.
DTEIT 19/8/

CG-6284

386

ANIMATOR
Animation basics

Procedural
motion: The
movement of particle systems is
sometimes
referred
to
as
procedural motion.
DTEIT 19/8/

CG-6284

387

ANIMATOR

Character Animation:

Character animation is the process of


imbuing objects not just with simple
movement, but with personality.The key to
compelling characters is making them act
naturally.
DTEIT 19/8/

CG-6284

388

ANIMATOR

Our graphics system might be useful in

producing animated films.


Animation is done by

photographing a sequence of drawings.

Each is slightly different from the

previous .
DTEIT 19/8/

CG-6284

389

ANIMATOR

To show a person moving his arm , a series

of drawings is photographed , each drawing


showing the arm at a different position.

When the images are displayed on the after

another by a movie projector, we perceive the


arm as moving through the sequence.
DTEIT 19/8/

CG-6284

390

ANIMATOR

ANIMATION OF ARM BY A SERIES OF PICTURE


DTEIT 19/8/

CG-6284

391

ANIMATOR

Our graphics system could be used to

generate the background drawing.

The scene is a city street . to show a

character moving down the street , we


really want to keep the character centered
and move the secenery past him.
DTEIT 19/8/

CG-6284

392

ANIMATOR

Each frame will show the background

shifted a little more to the right. This will


give the impression that our character has
moved to left.

DTEIT 19/8/

CG-6284

393

APPARENT MOVEMENT BY TRANSLATION


OF THE BACKGROUND
DTEIT 19/8/
CG-6284

394

VECTOR METHOD FOR SPLITTING


CONCAVE POLYGONS
E5

3
2
E4

E6

1
E1
0

E2

E3
2

SPLITTING A CONCAVE POLYGON USING


THE VECTOR METHOD

DTEIT 19/8/

CG-6284

395

VECTOR METHOD FOR


SPLITTING CONCAVE
POLYGONS

Previous figure shows a concave

Polygon with six edges. Edge vector for

this polygon can be expressed as :

DTEIT 19/8/

CG-6284

396

DTEIT 19/8/

CG-6284

397

PARALLEL PROJECTION
In a parallel projection, parallel lines in the
world-coordinate scene project into parallel
lines on the two-dimensional display playing.
This technique is used in engineering and
architectural drawings tools to represent and
object with set of views that maintain relative
properties of the object .

DTEIT 19/8/

CG-6284

398

PARALLEL PROJECTION

TOP

SIDE

FRONT

Fig:- Parallel-projection views of an object,


showing relative proportion from different viewing positions

DTEIT 19/8/

CG-6284

399

PARALLEL PROJECTION
The appearance of the solid object can then
be reconstructed from the major views.
In the perspective projection, parallel lines
in a scene that are not parallel to display plane
are projected into converging lines.

Scenes displayed using perspective


projections appear more realistic.

DTEIT 19/8/

CG-6284

400

DEPTH CUEING
With few exceptions, depth information is
important so that we can easily identify, for a
particular viewing direction, which is the front
and which is the back of displayed objects.

A simple method indicating depth with


wire frame displays is to vary the intensity of
objects according to their distance from the
viewing position.

DTEIT 19/8/

CG-6284

401

DEPTH CUEING

The lines closest to the viewing position are


displayed with the highest intensities and lines
further away are displayed with decreasing
intensities.
Depth cueing is applied by choosing maximum
and minimum intensity values and range of
distances over which the intensities are to the
vary.

DTEIT 19/8/

CG-6284

402

DEPTH CUEING
Depth cueing is used in modeling the
effect of atmosphere on the perceived
intensity of objects .
Some atmospheric effects can change
the perceived color of an object, and we
can model these effects with depth cueing.
DTEIT 19/8/

CG-6284

403

VISIBLE LINE AND


SURFACE IDENTIFICATION
We can clarify depth relationships in a wire
frame display by identifying visible lines in
some way .
The simplest method is to highlight the visible
lines or to display them in different color.

Another technique commonly used for


engineering drawings is to display the non
visible lines as dashed lines.
DTEIT 19/8/

CG-6284

404

SURFACE RENDERING

Added realism is attained in displays by


setting the surface intensity of object according
to the lighting conditions in the scene and
according to assigned surface characteristic.

Lighting specifications include the intensity


and positions of light sources.

DTEIT 19/8/

CG-6284

405

SURFACE RENDERING
Surface properties of objects include degree
of transparency and how rough or smooth
the surfaces are to be.
Procedures can then be applied to generate
the correct illumination and shadow
regions for the scene.
DTEIT 19/8/

CG-6284

406

EXPLODED AND CUTAWAY


VIEWS
Many graphics packages allow objects to be
defined as hierarchical structures, so that the
internal details can be stored.
Exploded and cutaway views of such objects
can then be used to show the internal
structure and relationships of the object parts.
DTEIT 19/8/

CG-6284

407

THREE DIMENSIONAL AND


STEREOSCOPIC VIEWS
It is the method for adding a sense of realism to
a computer- generated scene is to display objects
using either three dimensional or stereoscopic
views .
Three dimensional views can be obtained by
reflecting a raster image from a vibrating
flexible mirror.

DTEIT 19/8/

CG-6284

408

THREE DIMENSIONAL AND


STEREOSCOPIC VIEWS
The vibrations of the mirror synchronized with
the display of scene on the CRT.
As the mirror vibrates the focal length varies so
that each point in the scene is projected to a
position corresponding to its depth.

DTEIT 19/8/

CG-6284

409

THREE DIMENSIONAL AND


STEREOSCOPIC VIEWS
Stereoscopic devices present two views of a scene :
# One for the left eye
# other for the right eye.
The views are generated by selecting viewing
positions that correspond to the two eye positions
of a single viewer.

DTEIT 19/8/

CG-6284

410

THREE DIMENSIONAL AND


STEREOSCOPIC VIEWS
These two views then can be displayed on
alternate refresh cycles of a raster monitor
and viewed through glasses that alternately
darken first one lens then the other in
synchronization with the monitor refresh
cycles.
DTEIT 19/8/

CG-6284

411

THREE-DIMENSIONAL
DISPLAY METHODS
To obtain a display of a three dimensional
scene that has been modeled in world coordinates, we must first set up a coordinate
reference for a camera.
This coordinate reference defines the
position and orientation for the plane of the
camera film, which is the plane we want to use
to display a view of the object in the scene.

DTEIT 19/8/

CG-6284

412

THREE-DIMENSIONAL
DISPLAY METHODS
Object descriptions are then transferred to the
camera reference coordinates and projected onto
the selected display plane.
We can then display the objects in wire
frame form or we can apply lighting and surfacerendering techniques to shade the visible
surfaces.

DTEIT 19/8/

CG-6284

413

THREE-DIMENSIONAL
DISPLAY METHODS

DTEIT 19/8/

CG-6284

414

COORDINATE
PRESENTATIONS
Refresh
display
Picture
Definition in
World
Coordinates

Normalized
Coordinates

Device
coordinates

Plotter

Other
displays

Ymax

1
x
0
DTEIT 19/8/

0
CG-6284

Xmax
415

COORDINATE
PRESENTATIONS

A transformation from a users picture


definition (world coordinates) to normalized
coordinates is often performed by graphics
system in order to provide an interface to
different types of output device.

DTEIT 19/8/

CG-6284

416

VIEWING IN 3-D
3D WORLD
COORDINATE
OUTPUT PRIMITIVES
CLIPPED
WORLD
COORDINATES

CLIP AGAINST
VIEW
VOLUME

PROJECT ONTO
PROJECTION
PLANE

2D DEVICE
COORDINATES

TRANSFORM
INTO VIEWPORT
IN 2D DEVICE
COORDINATES
FOR DISPLAY

CONCEPTUAL MODEL OF THE 3D VEIWING PROCESS


DTEIT 19/8/
CG-6284
417

VIEWING IN 3-D
In 3d viewing, we specify a view volume in
the world, a projection on to a projection plane,
& a viewport on the view surface. Conceptually,
objects in 3d world are clipped against the 3d
view volume & are then projected. The contents
of the projection of the view volume onto the
projection plane called the window, are then
transformed into the viewport for display.
DTEIT 19/8/

CG-6284

418

GENERAL PARALLEL PROJECTION


TRANSFORMATION
In phigs, the direction of a parallel
projection is specified with a projection
vector from the reference point to the
center of the view window.
The general shape of a finite view
volume for a given projection vector
and projection window in the view
plane.
DTEIT 19/8/

CG-6284

419

View-plane positioning to simulate a camera Frame for an


animation sequence.

MOTION

WINDOW

SCIENCE

ZPRP=0

DTEIT 19/8/

ZV

VIEW PLANE

CG-6284

420

GENERAL PARALLEL
PROJECTION TRANSFORMATION
We obtain the oblique-projection transformation
with a shear operation that converts the view
volume to the regular parallelepiped.
The elements of the shearing transformation
needed to generate the view volume are obtained
by considering the shear transformation of the
projection vector.

DTEIT 19/8/

CG-6284

421

Regular parallelepiped view volume obtained by


shearing the view volume.
ZV
N

VP
VIEW VOLUME

DTEIT 19/8/

CG-6284

422

OBLIQUE PROJECTION VECTOR AND


ASSOCIATED VIEW VOLUME.
ZV
N

WINDOW

VP
VIEW VOLUME

DTEIT 19/8/

CG-6284

423

GENERAL PARALLEL
PROJECTION TRANSFORMATION
Suppose the elements of the projection vector in
coordinates are
vp=(px,py,pz).
We need to determine the elements of a shear matrix
that will align the projection vector vp with the view
plane normal vector n. This transformation can be
expressed as
VP=MPARALLEL.VP

DTEIT 19/8/

CG-6284

424

0
0
=

PZ
0

Where Mparallel is equivalent to projection matrix 12-10


and represents a 2-axis shear of the form

1 0 a 0
MPARALLEL=

0 1 b 0
0 0 1 0
0 0 0 1

DTEIT 19/8/

CG-6284

425

GENERAL PARALLEL
PROJECTION TRANSFORMATION
The explit transformation equations from
12-20 in terms of shear parameters a and b are
0 = px + apz
0 = py + bpz
So that the values for the shear parameters are
a= - px/pz, b= -py/pz

DTEIT 19/8/

CG-6284

426

GENERAL PARALLEL
PROJECTION TRANSFORMATION
Thus,we have the general parallelprojection matrix in terms of the elements
of the projection vector as
1 0 -PX/PZ 0
MPARALLEL=

DTEIT 19/8/

0 1 -PY/PZ 0
0 0

0 0

1
CG-6284

427

GENERAL PARALLEL
PROJECTION TRANSFORMATION
This matrix is then concatenated with

transformation r .T1 to produce the


transformation from world coordinates to
parallel-projection coordinates.
For an orthographic parallel projection,

px=p x=0 and m parallel is the identity


matrix.
DTEIT 19/8/

CG-6284

428

GENERAL PARALLEL
PROJECTION TRANSFORMATION
We can relate the components of the
projection vector to parameters l,
and
phi.By similar triangles,we see that

l cos /z = - px/pz

L sin /z = - py/pz
which illustrate the equivalence of the
elements of transformation matrices 12-10
and 12-24.
DTEIT 19/8/

CG-6284

429

Relationship between the parallel projection vector V p


and parameters l,alpha and phi.
YY

(XP,YP,0 )

VP
PY
PZ

PX
(X,Y,O)

DTEIT 19/8/

XY

CG-6284

ZY

430

GENERAL PERSPECTIVE
PROJECTION TRANSFORMATION
With the PHIGS programming standard,
the projection reference point can be
located at any position in the viewing
system,except on the view plane or
between the front and back clipping planes.
DTEIT 19/8/

CG-6284

431

GENERAL PERSPECTIVE
PROJECTION TRANSFORMATION
The figure shows the shape of a finite
view volume for an arbitrary position of the
projection reference point.

DTEIT 19/8/

CG-6284

432

GENERAL PARALLEL
PROJECTION TRANSFORMATION
We can obtain the general perspective
projection
transformation
with
the
following two operations:

Shear the view volume so that the


centerline of the frustum is perpendicular to
the view plane.

DTEIT 19/8/

CG-6284

433

GENERAL PARALLEL
PROJECTION TRANSFORMATION
Scale the view volume with a scaling
factor that depends on 1/z.
The second step (scaling the view volume)
is
equivalent
to
the
perspective
transformation.

A shear operation to align a general


perspective view volume with the projection
window.

DTEIT 19/8/

CG-6284

434

General shape for the perspective view volume with a


projection reference point that is not on the zv axis.
FRUSTUM CENTERLINE

ZY

VIEW PLANE
CENTER OF WINDOW
DTEIT 19/8/

(XPRP,YPRPCG-6284
,ZPRP)

435

GENERAL PARALLEL
PROJECTION TRANSFORMATION
This transformation has the effect of
shifting all positions that lie along the
frustum centerline ,including the window
center ,to a line perpendicular to the view
plane.With the projection reference point at
a general position (xprp,yprp,zprp),the
transformation involves a combination zaxis shear and a translation:
DTEIT 19/8/

CG-6284

436

GENERAL PARALLEL
PROJECTION TRANSFORMATION

MSHEAR =

DTEIT 19/8/

-azprp

-bzprp

CG-6284

437

GENERAL PARALLEL
PROJECTION TRANSFORMATION
Where the parameters are :

a= (-xprp-(xwmin+xwmax)/2)/zprp
b= (-yprp-(ywmin+ywmax)/2)/zprp
Points within the view volume are
transformed by this operation as
the zp axis, xprp= yprp= 0
DTEIT 19/8/

CG-6284

438

GENERAL PARALLEL
PROJECTION TRANSFORMATION
x= x + a(z-zprp)
y= y + b(z-zprp)
z= z
when the projection reference point is on

DTEIT 19/8/

CG-6284

439

Shearing a general perspective view volume to center it


on the projection window.
Frustum
centerline
(x,y,z)
zv
(x,y,z)

View plane
Center of window
(xprp,yprp,zprp)
DTEIT 19/8/

CG-6284

440

GENERAL PARALLEL
PROJECTION TRANSFORMATION
The complete transformation from world
coordinates to perspective projection
coordinates is obtained by right
concatenating m perspective with the
composite viewing transformation R.T
DTEIT 19/8/

CG-6284

441

PARALEL PROJECTION
We have talked about creating and transforming
three-dimensional objects, but since our viewing
surface is only two-dimensional, we must have some
way of projecting our three -dimensional object onto
the two -dimensional screen.

DTEIT 19/8/

CG-6284

442

PARALEL PROJECTION
Perhaps the simplest way of doing this is
just to discard the z coordinate. This is a
special case of a method known as parallel
projection. A parallel projection is formed
by extending parallel line from each vertex
on the object until by they intersect the plan
of the screen.
DTEIT 19/8/

CG-6284

443

PARALEL PROJECTION
Y AXIS

X AXIS
3 D OBJECT
Z AXIS
DTEIT
19/8/

CG-6284

444

PARALEL PROJECTION
Y AXIS

X AXIS
PROJECTION OF OBJECT
A THREE- DIMENSIONAL OBJECT AND ITS PROJECTION
DTEIT 19/8/
CG-6284
445

ALGORITHM PARALLELTRANSFORM (X, Y, Z)


Parallel projection of a point :Arguments X,Y,Z the point to be projected,
also for return of result
Global
SXP,SYP the parallel projection
vector
ratios
BEGIN
X <-- X - Y * SXP ;
Y <-- Y - Z * SYP ;
RETURN ;
END ;
DTEIT 19/8/

CG-6284

446

ALGORITHM PERSPECTIVETRANSFORM (X, Y, Z)


For perspective projection of a point:Arguments X,Y,Z the view plane coordinates of
the point
Global
XC,YC,ZC the center of projection
Local
D the denominator in the calculation
Constant
ROUNDOFF some small number
greater than any roundoff error
VERY-LARGE a very-large number
approximating infinity
DTEIT 19/8/

CG-6284

447

ALGORITHM PERSPECTIVETRANSFORM (X, Y, Z)


BEGIN
D <-- ZC - Z
IF |D| < ROUNDOFF THEN
BEGIN
X <-- ( X - XC ) * VERY - LARGE
Y <-- ( Y- YC ) * VERY- LARGE
Z <-- VERY-LARGE
END
DTEIT 19/8/

CG-6284

448

ALGORITHM PERSPECTIVETRANSFORM (X, Y, Z)


ELSE
BEGIN
X <-- ( X * ZC - XC * Z ) / D;
Y <-- ( Y * ZC - YC * Z ) / D;
Z <-- Z / D ;
END;
RETURN;
END;
DTEIT 19/8/

CG-6284

449

THE VARIOUS KINDS OF


PROJECTION
We can construct different projections
according to the view that is desired. It
provides a taxonomy of the families of
perspective and parallel projections. Some
projections have names -cavalier,cabinet,
isometric , and so on. Other projections qualify
the main type of projection - one principle
vanishing-point perspective, and so forth.

DTEIT 19/8/

CG-6284

450

PROJECTIONS
Perspective
One principal
vanishing point

Parallel
Oblique
Projectors not
perpendicular

Two principal
vanishing point
Three principal
vanishing point

DTEIT 19/8/

to projection
plane

Orthographic
Projectors not
perpendicular

to projection plane
Multiview Axonometric
Projection
Projection
General
plane llel to
plane not llel
principal
to principal
Cavalier
planes
planes
Isometric, Dimetric
Cabinet Three views ,
Trimetric 451
CG-6284
Auxiliary
views

PERSPECTIVE PROJECTION
BASIC PRINCIPLES:The techniques of perspective projection are
generalizations of the principles used by artists
in preparing perspective drawings of threedimensional objects and scenes. The eye of the
artists is placed at the center of projection,and
the canvas,or more precisely the plane
containing the canvas,becomes the view plane

DTEIT 19/8/

CG-6284

452

PERSPECTIVE PROJECTION
An image point is located at the intersection of
a projector with the view plane.
Perspective drawings are characterized by
perspective foreshortening and vanishing
points.
Perspective foreshortening is the illusion that
objects and lengths appear smaller as their
distance from the center of projection increases.
DTEIT 19/8/

CG-6284

453

PERSPECTIVE PROJECTION
The illusion that certain sets of parallel lines
appear to meet at a point is another feature of
perspective drawings. These points are called
vanishing points.
Principle vanishing points are formed by the
apparent intersection of lines parallel to one of
the three principle x,y,or z axes.
The no. of principle vanishing points is
determined by the no. of principle axes
intersected by the view plane.
DTEIT 19/8/

CG-6284

454

PERSPECTIVE PROJECTION
EXAMPLE:-The standard perspective projection.
The view plane is the xy plane , and the center of
projection is taken as the point C(0,0,-d) on the
negative z axis.
Using similar triangles ABC and A 0C , we find
x`=d*x/z+d
y`=d*y/z+d
z`=0
DTEIT 19/8/

CG-6284

455

PERSPECTIVE PROJECTION
The perspective transformation between
objects and image point is nonlinear & so
cannot be represented as a 3*3 matrix
transformation.
However , if we use homogeneous
coordinates, the perspective transformation
can be represented as a 4*4 matrix:
DTEIT 19/8/

CG-6284

456

PERSPECTIVE PROJECTION

X`
Y`

D* X
=

Z`
1

D* Y
0

0 0

D 0

1 D

Z+D

The general form of perspective transformation is


developed
DTEIT 19/8/

CG-6284

457

PERSPECTIVE ANOMALIES
The process of constructing a perspective
view introduces certain anomalies which
enhance realism in turns of depth cues but
also distort actual sizes and shapes.
Perspective foreshortening:- The farther an
object is from the center of projection, the
smaller it appears.
DTEIT 19/8/

CG-6284

458

PERSPECTIVE ANOMALIES
Vanishing point:-Projections of lines that
are not parallel to the view plane(i.e.,lines
that are not perpendicular to the view plane
normal) appear to meet at some point on
view plane. A common manifestation of
this anomaly is the illusion that railroad
tracks meet at a point on the horizon.
19/8/
DTEIT

CG-6284

459

PERSPECTIVE ANOMALIES
VIEW PLANE
Y

C(0,0,-D)

Sphere B is 2.5 times the size of sphere A ; yet both spheres


appear to be the same size when projected on to the view plane
DTEIT 19/8/

CG-6284

460

You might also like