CG-module 4 Notes
CG-module 4 Notes
POLYGON CLIPPING
To clip polygons, we need to modify the line-clipping procedures. A polygon boundary
processed with a line clipper may be displayed as a series of unconnected line segments,
depending on the orientation of the polygon to the clipping window.
Convex polygons are correctly clipped by the Sutherland-Hodgeman algorithm, but concave
polygons may be displayed with extraneous lines. This occurs when the clipped polygon
should have two or more separate sections. But since there is only one output vertex list,
the last vertex in the list is always joined to the first vertex
Weiler- Atherton Polygon Clipping
This clipping procedure was developed as a method for identifying visible surfaces,
and so it can be applied with arbitrary polygon-clipping regions.
The basic idea in this algorithm is that instead of always proceeding around the
polygon edges as vertices are processed, we sometimes want to follow the window
boundaries. Which path we follow depends on the polygon-processing direction (clockwise
or counter clockwise) and whether the pair of polygon vertices currently being processed
represents an outside-to-inside pair or an inside- to-outside pair. For clockwise processing
of polygon vertices, we use the following rules:
For an outside-to-inside pair of vertices, follow the polygon boundary.
For an inside-to-outside pair of vertices,. follow the window boundary in a clockwise
direction.
In the below Fig. the processing direction in the Weiler-Atherton algorithm and the
resulting clipped polygon is shown for a rectangular clipping window.
Curve Clipping
Curve-clipping procedures will involve nonlinear equations, and this requires more
processing than for objects with linear boundaries. The bounding rectangle for a circle or
other curved object can be used first to test for overlap with a rectangular clip window. If
the bounding rectangle for the object is completely inside the window, we save the object.
If the rectangle is determined to be completely outside the window, we discard the object.
In either case, there is no further computation necessary. But if the bounding rectangle test
fails, we can look for other computation-saving approaches. For a circle, we can use the
coordinate extents of individual quadrants and then octants for preliminary testing before
calculating curve-window intersections.
The below figure illustrates circle clipping against a rectangular window. On the first pass,
we can clip the bounding rectangle of the object against the bounding rectangle of the clip
region. If the two regions overlap, we will need to solve the simultaneous line-curve
equations to obtain the clipping intersection points.
Three-Dimensional Object Representations
Representation schemes for solid objects are divided into two categories as follows:
It describes a three dimensional object as a set of surfaces that separate the object interior
from the environment. Examples are polygon facets and spline patches.
It describes the interior properties, by partitioning the spatial region containing an object
into a set of small, nonoverlapping, contiguous solids(usually cubes).
Eg: Octree Representation
Polygon Surfaces
Polygon surfaces are boundary representations for a 3D graphics object is a set of polygons
that enclose the object interior.
Polygon Tables
The polygon surface is specified with a set of vertex coordinates and associated attribute
parameters. For each polygon input, the data are placed into tables that are to be used in
the subsequent processing. Polygon data tables can be organized into two groups:
Geometric tables and attribute tables.
Geometric Tables Contain vertex coordinates and parameters to identify the spatial
orientation of the polygon surfaces.
Attribute tables Contain attribute information for an object such as parameters specifying
the degree of transparency of the object and its surface reflectivity and texture
characteristics.
ROTATION
Coordinate-Axes Rotations
The two-dimensional z-axis rotation equations are easily extended to three dimensions:
SCALING
The matrix expression tor the scaling transformation of a position P = (x, y, z) relative
to the coordinate origin can be written as
General Three-Dimensional Rotations
A rotation matrix for any axis that does not coincide with a coordinate axis can be set
up as a composite transformation involving combinations of translations and the coordinate-
axes rotations.
An object is to be rotated about an axis that is parallel to one of the coordinate axes,
We can attain the desired rotation with the following transformation sequence.
1. Translate the object so that the rotation axis coincides with the parallel coordinate axis.
2. Perform the specified rotation about that axis.
3. Translate the object so that the rotation axis is moved back to its original position.
An object is to be rotated about an axis that is not parallel to one of the
coordinate axes
In this case, we also need rotations lo align the axis with a selected coordinate axis and to
bring the axis hack to its original orientation. Given the specification s for the rotation axis
and the rotation angle, we can accomplish the required rotation in five steps shown in fig 11.9
1 Translate the object so that the rotation axis passes through the coordinate origin.
2. Rotate the object so that the axis of rotation coincides with one of the coordinate axes.
3. Perform the specified rotation about that coordinate axis.
4. Apply inverse rotations to bring the rotation axis back to its original orientation.
5. Apply the inverse translation to bring the rotation axis back to its original position.
A rotation axis can be defined with two coordinate positions, as in Fig. 11-10. We will
assume that the direction of rotation is to be counter clockwise when looking along the axis
from P2 to P1.
Where the components a, b, and c of unit vector u are the direction cosines for the rotation
axis:
The first step in the transformation sequence for the desired rotation is
Set up the translation matrix that repositions the rotation axis so that it passes through
the coordinate origin. we accomplish this by moving point PI to the origin. This translation
matrix which repositions the rotation axis and the object, as shown in Fig. 11-11 is
Now we need the transformations that will put the rotation axis on the z axis. We can use the
coordinate-axis rotations to accomplish this alignment in two steps.
1. We will first rotate about the x axis to transform vector u into the xz plane.
2. Then we swing u around to the z axis using a y-axis rotation.
These two rotations are illustrated in Fig. 11-12 for one possible orientation of vector u.
Since rotation calculations involve sine and cosine functions, the standard vector operations
can be used to obtain elements of the two rotation matrices. Dot-product operations allow us
to determine the cosine terms, and vector cross products provide a means for obtaining the
sine terms.
We establish the transformation matrix for rotation around the x axis by determining the
values for the sine and cosine of the rotation angle necessary to get u into the xz plane. This
rotation angle is the angle between the projection of u in the yz plane and the positive z axis.
If we designate the projection of u in the yz plane as the vector u' = (0, b, c), then the cosine
of the rotation angle α can be determined from the dot product of u' and the unit vector uz,
along the z axis:
This matrix rotates unit vector u about the x axis into the xz plane.
Next, determine the transformation matrix that will swing the unit vector in the xz plane
counterclockwise around the y axis onto the positive z axis.
Here, the vector, labeled u" is orientation of the unit vector in the xz plane (after rotation
about the x axis) . This vector, labeled u", has the value a for its x component, since rotation
about the x axis leaves the x component unchanged. Its z component is d (the magnitude of
u'), because vector u' has been rotated onto the z axis. And the y component of u" is 0,
because it now lies in the xz plane.
Again, we can determine the cosine of rotation angle β from expressions for the dot product
of unit vectors u" and u,:
With transformation matrices 11-17, 11 -23, and 11-28, we have aligned the rotation axis
with the positive z axis.
The specifled rotation angle Ɵ can now be applied as a rotation about the z axis:
To complete the required rotation about! the given axis, we need to transform the rotation
axis back to its original position. This is done by applying the inverse of transformations 11-
17, 11-23, and 11-28.
The transformation matrix for rotation about an arbitrary axis then can be expressed as the
composition of these seven individual transformations: