You are on page 1of 14

Computer Graphics

U N I T

Geometric

Objects

- 4

and Transformations

Related to three-dimensional graphics:

Representations of basic geometric types


Conversion between various representations
Representation independent statements on geometric objects

4.1 Scalars, Points, and Vectors


In computer graphics, most of geometric objects can be defined using a limited set of simple
entities (geometric objects) like:

scalars
points and
vectors

These basic entities can be defined in at least three different ways: from a

geometric perspective
mathematical perspective or
programming (computer-science) perspective

To understand the difference between the mathematical definition of each type and the particular
implementation of that type, the study of underlying mathematics is required.
4.1.1 The Geometric View
POINT

In a three-dimensional geometric system, a point is a location in space.

The only attribute that a point possesses is that point's location; a mathematical point does
not even have a size.

Points exist in space regardless of any reference or coordinate system.

SCALARS

Scalars are always the real numbers.

Although scalars lack geometric properties, scalars are used as units of measurement.

For example, the length of a line segment is scalar.

VECTORS

The directed line segments (vectors) connecting points are called vectors. The term vector is
used for any quantity with direction and magnitude.

Physical quantities, such as velocity and force, are vectors.

A vector does not have a fixed position.

In the below figure, three vectors are identical because they have the same direction
(orientation) and magnitude (length). They are identical, although their positions differ.

The length and the direction of a vector can be changed by real numbers.

Priyanka H V

Page 1

Computer Graphics

In the figure, vector A has the same direction as line segment


B, but B has twice the length that A has i.e., B = 2A.

Vector C has the same length as A but points in the opposite


direction, so C = -A. There sum forms a special vector
called

the zero vector, which is denoted as 0,that has a magnitude of zero

Combining vectors: Vectors can be combined by the head-to-tail rule.

In the figure, head of vector A is connected to the tail of vector B


to form a new vector C whose magnitude and direction are
determined by the line segment from the tail of A to the head of
B so, C = A + B.

Operation between points and vectors:

Points and vectors are two distinct geometric types. Two operation takes place between
them:
point-vector addition
point-point subtraction

Point-Vector addition:

Figure shows the operation taking place between points and directed line segments (vectors).

A directed line segment is moved from one point to another. This operation is called as pointvector addition, and it produces a new point.

This operation can be written as P=Q + v.

The vector v displaces the point Q to the new location P.

Point-Point subtraction

Any two points dene a directed line segment or vector from one point to the second.This
operation is called as point-point subtraction.

This operation can be written as v=PQ.

4.1.2 Co-ordinate-Free Geometry


Refer text book
4.13 The Mathematical View: Vector, Affine and Euclidean Spaces

Points, Scalars, and Vectors can be considered as members of mathematical sets.

Mathematics defines a variety of spaces to represent and manipulate these members.

Three spaces are


Vector (Linear) Space
Affine Space
Euclidean space
Priyanka H V

Page 2

Computer Graphics

Vector (Linear) Space

A vector space contains two distinct entities:


vectors and
scalars

rules to perform operations on them

Operation between Scalars:

Scalars can be combined with the rules (operations) called addition and multiplication.

Operation between a scalar and a vector:

A scalar and a vector can be combined with in a vector space, to form new vector through
scalar-vector multiplication.

Operation between vectors:

Vector can be combined with another vector through vector-vector addition.

Examples of mathematical vector spaces include n-tuples of real numbers, the solution of
homogeneous linear differential equations, and the geometric operations on vectors.
Euclidean space

In a linear vector space, there is no way of measuring a scalar quantity.

A Euclidean space is an extension that adds a measure of size or distance.

In these abstract spaces, objects can be defined independently of any particular


representation. But representations provide the tie between abstract objects and their
implementation, and conversion between representations leads to geometric
transformations.

Affine Space
An affine space is an extension of the vector space that includes an additional type of
object: the point and rules to perform operations on them.
Operation between points:

There are no operations between two points.

Operation between point and scalar:

There are no operations between a point and a scalar.

Operation between point and vector:

Vector-Point addition: is an operation in affine space that produces a new point.

Point-Point subtraction: is an operation in affine space that produces a vector.

Examples of affine spaces include the geometric operations on points and vectors and the
solution of linear inhomogeneous ordinary differential equations.

4.1.4 The Computer-Science View

The computer-Science view points, scalars and vectors as abstract data types (ADTs).

An ADT is a set of operations on data; the operations are defined independently of how
the data are represented internally or of how the operations are implemented.

From a computational point of view, the geometric objects can be declared through code
such as
vector u, v;
point

Priyanka H V

Page 3

p, q;

Computer Graphics

scalar a, b;
regardless of the internal representation or implementation of the objects on a particular
system.
4.1.5 Geometric ADTs

Points, Scalars and Vectors with their geometric, Mathematical and Computer Science Views
can be used to perform geometrical operations and to form new objects.
Let P, Q, R, . . .define points;
Let , , , . . . denote scalars; and
Let u, v, w,. . . denote vectors.

For vectors and points, this notation refers to the abstract objects and this notation does not
refer to the representations of these objects in a particular reference system.

The magnitude of a vector v is a real number denoted by |v|.

Vector-Scalar Multiplication:

The operation of vector-scalar multiplication has the property that


|v| = |||v|

and the direction of v is the same as the direction of v if is positive.


Two equivalent operations that relate points and vectors:

First, subtraction of two points, P and Q-an operation that yields

a vector v denoted by v = P - Q.
Second, given any point Q and vector v, there is a unique point,

P.
This statement can be expressed as: Given a point Q and a vector
v, there is a point P such that P = v + Q. Thus, P is formed by a
point-vector addition operation.
Figure shows a visual interpretation of this operation.

Vector-vector addition:
The head-to-tail rule gives way of visualizing vector-vector addition.
The sum u + v is obtained as shown in below figure by drawing the sum vector as connecting
the tail of u to the head of v.

This can also be visualized for any three points P, Q, and R,


(P - Q) + (Q - R) = P R

Priyanka H V

Page 4

as shown below:

Computer Graphics

4.1.6 Lines

The sum of a point and a vector (or the subtraction of two points) leads to the notion of a line
in an affine space.

Consider all points of the form


P() = Po+ d
where Po is an arbitrary point, d is an arbitrary vector, and is a scalar.

Given the rules for combining points, vectors, and scalars in an affine space, P() is a point
for any value of .

For geometric vectors, these points lie on a line, as shown below:

This form is sometimes called the parametric form of the line,


because we generate points on the line by varying the parameter
a.

For =0, the line passes through the point Po and, as a is


increased, all the points generated lie in the direction of the
vector d.

If is restricted to non-negative values, ray emanating from Po and going in the direction of
d is obtained.

4.1.7 Affine Sums

In an affine space, the addition of two arbitrary points and the multiplication of a point by a
scalar are not defined. However, there is an operation called affine addition that has certain
elements of these latter two operations.

For any point Q, vector v, and positive scalar ,


P =Q + v

describes all points on the line from Q in the direction of v, as shown below:

A point R such that v = R Q can always be found.


Thus
P = Q + (R - Q) = R + (1 )Q

This operation looks like the addition of two points and leads
to the equivalent form
P =l R +2Q,

where l + 2 = 1.

4.1.8 Convexity

A convex object is one for which any point lying on the line segment connecting any two
points in the object is also in the object.

The affine sums help in deep understanding of convexity.

For 0 1, the affine sum defines the line segment connecting R and Q, as shown in figure
below.

Thus, this line segment is a convex object.

The affine sum can be extended to include objects defined by n


points P1, P2,. . ., Pn.

Priyanka H V

Page 5

Consider the form

Computer Graphics

P =1P1+ 2P2+ 3P3+ nPn

This sum is defined if and only if l + 2 + 3 + n= 1

Convex Hull : The set of points formed by the affine sum of n points, under the additional
restriction i 0, i = 1,2,3n, is called the convex hull of the set of points.

The convex hull is the set of points that form by


stretching a tight-fitting surface over the given set of
points - shrink wrapping the points.

It is the smallest convex object that includes the set of


points. The notion of convexity is extremely important in
the design of curves and surfaces.

4.1.9 Dot and Cross Products

Geometric concepts related to the orientation (direction) between two vectors are in the terms
of Dot product and Cross product.

DOT PRODUCT:

The dot product of u and v is written u.v.


If u.v = 0, u and v are orthogonal.
The square of the magnitude of a vector is
|u|2=u.u
The angle between two vectors u and v is given by

is the orthogonal projection of v onto u.

Given three linearly independent vectors in a three-dimensional space, dot product can be
used to construct three vectors, each of which is orthogonal to the other two.

CROSS PRODUCT:

Cross product of two non-parallel vectors, say u & v, gives a third vector, say n, that is
orthogonal to both u and v. i.e., n = u x v

The magnitude of the cross product gives the magnitude of the sine of the angle between u
and v

The vectors u, v, and n form a right-handed coordinate system.

u points in the direction of the thumb of the right hand, and v


points in the direction of the index finger, then n points in the

direction of the middle finger.


4.1.10 Planes

A plane in an affine space can be defined as a direct extension of the parametric line.

From simple geometry, the three points, not in a line, determine a unique plane.

Suppose that P, Q, and R are three such points in an affine space.

Priyanka H V

Page 6

Computer Graphics

The line segment that joins P and Q is the set of points of the form
S() = P + (1 - ) Q, 0 1.

Suppose an arbitrary point on this line segment is taken and


form the line segment from this point to R, as shown in
figure.

Using a second parameter , points along this line segment


can be described as

T() = S + (1 - ) R, 0 1

Such points are determined by both and , and form the plane determined by P, Q, and R.
Combining the preceding two equations, the equation of a plane is:
T(, ) = [ P + (1 - ) Q] + (1 - ) R

By rearranging,
T(, ) = [ P + (1 - ) Q] + (1 - ) R
T(, ) = P + (1 - ) (Q-P)] + (1 - ) (R-P)

(Q P) and (R P) are arbitrary vectors.

A plane defined by Po, u, and v can be written as,


T(, ) = Po + u + v

For 0 , 1, all the points T(, ) lie in the triangle formed by P, Q, and R.

If a point P lies in the plane, then


P - Po = u + v

A vector n that is orthogonal to both u and v is given by the cross product n =u x v.

Then the equation of the plane becomes n . (P - Po)= 0.

The vector n is perpendicular, or orthogonal, to the plane; it is called the normal to the
plane.

The forms P() for the line and T(, ) for the plane, are known as parametric forms,
because they give the value of a point in space for each value of the parameters and .

4.2 Three-Dimensional Primitives

3-D world provides more variety of geometric objects.

It retains even the objects available in 2-D world but they are no longer restricted to lie in the
same plane.

E.g.
1. 2-D curves become
2. Objects with interiors can
3.In addition, 3-D provides objects with volumes, curves in space become surfaces in space
such as parallelepipeds and ellipsoids

Priyanka H V

Page 7

Computer Graphics

Two problems in dealing 3D objects in a graphics system:

The mathematical definitions of these objects can become complex.


All objects cannot be implemented efficiently in graphics system. But, full range of 3-D
objects can be implemented by approximate methods.

Three features characterize three-dimensional objects that fit well with existing graphics
hardware and software:

The objects are described by their surfaces and can be thought of as being hollow:

Reason for this condition: This condition implies that only 2-D primitives are needed to model
3-D objects, because a surface is a two- rather than a 3-D entity. This is because the modern
graphics systems render triangular or other flat, polygons. High-end systems can render over 5
million small, flat polygons per second; boards in personal computers have rendering speeds of
over 1 million polygons per second.

The objects can be specified through a set of vertices in three dimensions.

Reason for this condition: If an object is defined by vertices, pipeline architecture can be used
to process these vertices at high rates, and hardware can be used to generate the images of the
objects only during rasterization.

The objects either are composed of or can be approximated by flat convex polygons.

Reason for this condition: Most graphics systems are optimized for the processing of points and
polygons. In 3-Ds, a polygon can be defined by an ordered list of vertices. However, if there are
more than three vertices, they do not have to be in the same plane; if they are not, there is no
simple way to define the interior of the object.
Triangular polygons are always flat, either the modeling system is designed always to produce
triangles, or the graphics system provides a method to divide, or tessellate, an arbitrary polygon
into triangular polygons.
If the same argument is applied to a curved object, such as to a sphere, small flat polygons can be
approximated to form the sphere. Hence, if the modeling system provides curved objects, it can
be assumed that a polygonal approximation is used for implementation.

Constructive Solid Geometry (CSG):

It is an approach of building objects from a small set of volumetric objects through


set operations such as union and intersection.

Although this approach is an excellent one for modeling, rendering CSG models is
more difficult than is rendering surface-based polygonal models.

4.3 Coordinate Systems and Frames

In a 3-D vector space, any vector w can be uniquely


represented in terms of any three linearly independent vectors,
v1, v2, and v3 as

Priyanka H V

Page 8

Computer Graphics

w =lv1 + 2v2 + 3v3

The scalars 1, 2, and 3 are the components of w with respect to the basis v1, v2, and v3.
These relationships are shown in the figure.

The same w can be represented with the column matrix:

This relationship can also be written as w = aT

These basis vectors define a coordinate system.

However, for dealing with problems using points, vectors, and scalars, a more general
method is needed.

Figure shows the problem.

The three vectors form a coordinate


system that is shown in figure (a) with
the three vectors emerging from a
single point.

These three basis vectors can be used as a basis to represent any vector in three dimensions.
Vectors, however, have direction and magnitude, but lack a position attribute.

Figure (b) is equivalent, because the basis vectors, are moved, leaving their magnitudes and
directions unchanged.

To represent points:

An affine space contains points, in such a space, once a particular reference point say -the
origin- is fixed, all other points can be represented unambiguously.

The usual convention for drawing coordinate axes is emerging from the origin, as shown in
above figure (a).

In the affine space both points and vectors have representations.

Frame is the representation which requires both the reference point and the basis vectors.

This extension fixes the origin of the vector coordinate system at some point Po. Within a
given frame, every vector can be written uniquely as
w =lv1 + 2v2 + 3v3.

just as in a vector space.

In addition, every point can be written uniquely as


P = Po + lv1 + 2v2 + 3v3.

Thus,
The representation of a particular vector in a frame requires three scalars.
The representation of a point requires three scalars and the knowledge of where the
origin is located.
4.3.2 Changes of Coordinate Systems

The representation of a vector changes when the basis vectors are changed.

Priyanka H V

Page 9

Computer Graphics

Suppose that {v1, v2, v3}and {u1, u2, u3} are two bases.

Each basis vector in the second set can be represented in terms of the first basis (and vice
versa). Hence, there exist nine scalar components, {ij }, such that

The 3 x 3 matrix

is defined by these scalars, and

M contains the information to go from a representation of a vector in one basis to its


representation in the second basis.

The inverse of M gives the matrix representation of the change from {u1, u2, u3} to {v1, v2,
v3}.

Consider a vector w that has the representation {1, 2, 3} with respect to {v1, v2, v3}
w =lv1 + 2v2 + 3v3

Equivalently, w = aT

where a =

Assume that b is the representation of w with respect to {u1, u2, u3} i.e.
w =lu1 + 2u2 + 3u3

or

w = bT

where b =

Then, using the representation of the second basis in terms of the first,

Thus, a = MTb.
Priyanka H V

Page 10

Computer Graphics

The matrix (MT)-1 moves from a to b:


b = Aa = (MT)-1 a

This result indicates that abstract vectors can be worked with column matrices of scalars - the
vectors' representations.

These changes in basis leave the origin unchanged. These

changes can be used represent rotation and scaling of a set of basis


vectors to derive another basis set, as shown in figure.

However, a simple translation of the origin, or change of

frame, as shown in figure, cannot be represented in this way.


Note:Example refer class notes

4.3.3 Homogeneous Coordinates:

A point P located at (x, y, z) can be represented using a 3-D frame determined by Po, v1, v2,
and v3, with the column matrix:

where x, y, and z are the components of the basis vectors for this point, so that,
P = Po + xv1 + yv2 + zv3

If the point is represented this way, then its representation is of the same form as the vector
w =lv1 + 2v2 + 3v3

Then w can be represented as w =

The vector from the point (1,1,1) to (2,3,4) is the same as the vector from (0,0,0) to (1,2,3),
because they have the same magnitude and direction, but the first vector would not be
associated with point (1,2,3) unless one end of it is fixed to (0,0,0). Here points and vectors

are maintained preferably as distinct geometric types.


In addition, failure to distinguish between points and vectors can make implementation more
difficult because a matrix multiplication in 3-Ds cannot represent a change in frames.

Another approach is used which uses homogeneous-coordinates to avoid these difficulties by


using 4-D column matrices to represent both points and vectors in 3-Ds.

In the frame specified by ( v1, v2, v3, Po), any point P can be written uniquely as
P = lv1 + 2v2 + 3v3 + Po

If the "multiplication" of a point by the scalars 0 and 1 is defined as


0.P = 0 and 1.P= P

The aforesaid relation can be represented formally, using a matrix product, as

Priyanka H V

Page 11

Computer Graphics

The 4-D row matrix on the right side of the equation is the homogeneous-coordinate
representation of the point P in the frame determined by (v1, v2, v3, Po).

Equivalently, it can be said that P is represented by the column matrix, P =

In the same frame, any vector w can be written

Thus, w can be is represented by the column matrix,

w=

There are numerous ways to interpret this formulation geometrically. The operations on
points and vectors can be carried out using their homogeneous-coordinate representations
and ordinary matrix algebra.

Consider a change of frames - a problem that caused difficulties when in 3-D representations.
If (v1, v2, v3, Po) and (u1, u2, u3, Q0) are two frames, then the basis vectors and reference point
of the second frame can be expressed in terms of the first as:

These equations can be written in the form:

where now M is the 4 x 4 matrix:

M is called the matrix representation of the change of frames.

M can also be used to compute the changes in the representations directly.

Suppose that a and b are the homogeneous-coordinate representations either of two points or
of two vectors in the two frames. Then,

Hence a = MTb
Advantages of using homogeneous coordinates:
Priyanka H V

Page 12

Computer Graphics

All affine (line-preserving) transformations can be represented as matrix multiplications in


homogeneous coordinates. Although 4-D work is involved in solving 3-D problems, less
arithmetic work is involved when homogeneous coordinates are used.
The uniform representation of all affine transformations makes carrying out successive
transformations (concatenation) far easier than in 3-D space.
In addition, modern hardware implements homogeneous-coordinate operations directly,
using parallelism to achieve high-speed calculations.
Example of Change in Frames:

Assume a vector w whose representation in some basis is

These three basis vectors can be denoted as v1, v2, v3.


w =v1 + 2v2 + 3v3

Assume that a new basis is to be made from the three vectors v1, v2, and v3.
u1 = v1
u2 = v1+v2
u3 = v1+v2+v3

Since the reference point is not changed following equation is added: Q0 = P0

Thus, the matrices of interest are the following matrix, its transpose and inverse:

Suppose that in addition to changing the basis vectors, it is needed to move the reference
point to the point that has the representation (1,2,3,1 ) in the original system.

The displacement vector v =v1 + 2v2 + 3v3 moves Po to Qo.

The fourth component identifies this entity as a point. Thus, the three equations are added
from the previous example, the equation
Q0 =P0 + v1 + 2v2 + 3v3

Matrix MT becomes

Its inverse is: A = (MT)-1 =

This pair of matrices allows moving back and forth between representations in the two
frames.

Priyanka H V

Page 13

Computer Graphics

A takes the point (1,2,3) in the original frame whose representation is P =

to P' =

the

origin in the new system.

The vector (1,2,3) which is represented as a =

in the original system is transformed to b =

, a transformation that is consistent with the results from the example of change in
coordinate systems, and that also demonstrates the importance of distinguishing between
points and vectors.

Priyanka H V

Page 14

You might also like