CG Unit - 2
CG Unit - 2
Polygons: Polygons and its types, inside test, Polygon filling methods: Seed – Flood
fill and Boundary Fill, Scan-line Fill algorithm 2D Transformations: Translation,
Scaling, Rotation, Reflection and Shearing, Matrix representation and homogeneous
coordinate system, composite transformations 3D Transformation: Translation, scaling,
rotation about X, Y, Z & arbitrary axis, and reflection about XY, YZ, XZ & arbitrary
plane.
Projections: Types of projections- Parallel, Perspective Parallel oblique: Cavalier,
Cabinet, Orthographic isometric, diametric, trimetric Perspective: vanishing points as 1
point, 2 point and 3 point.
08 Hours
Polygons
Example of Polygon:
• Triangle
• Rectangle
• Hexagon
• Pentagon
Polygons
Following figures shows some polygons.
Polygons
Types of Polygons
• Concave: A non-convex polygon is said to be
concave. A concave polygon has one interior angle
greater than 180°. So that it can be clipped into
similar polygons.
If these points lies on the same side of the constructed line A’P’, then the intersection point
counts as an even number of intersection. But if they lie on the opposite side of constructed
line AP, then the intersection points counts as a single intersection.
Even-Odd method :
Example : To test a point (xi, yi), let us consider a horizontal line segment y = yi which
runs from outside the polygon to (xi, yi). We find all the sides which crossed this line
segment.
Now there are 2 ways for side to cross, the side could be drawn starting below end, cross it
and end above the line. In this case we can give direction numbers – 1, to the side or the
edge could start above the line & finish below it in this case, given a direction 1. The sum
of the direction numbers for the sides that cross the constructed horizontal line segment
yield the “Winding Number” for the point.
If the winding number is non-zero , the point is interior to polygon, else, exterior to
polygon.
Winding Number Method :
In the above figure, the line segment crosses 4
edges having different direction numbers : 1, -1,
1& -1 respectively, then :
Winding Number = 1 + (-1) + 1 + (-1) = 0
So the point P is outside the Polygon. The edge
has direction Number -1 because it starts below
the line segment & finishes above. Similarly,
edge has direction Number +1 because it starts
from above the line segment & finishes below
the line segment (See the directions in the
figure).
Polygon filling Method :
Advantages:
• This method is easy to fill colors in computer graphics.
• It fills the same color inside the boundary.
Disadvantages:
• Fails with large area polygons.
• It is a slow method to fill the area.
Polygon filling Method :
Advantages:
• The boundary fill algorithm is used to create attractive paintings.
Disadvantages:
• In the 4-connected approach, it does not color corners.
Polygon filling Method :
Advantages:
• Scan fill algorithm fills the polygon in the same order as rendering.
• It takes advantage of coherence thus, a fast algorithm.
Disadvantages:
• The intensity of the pixels is unequal.
• Staircase-like appearance when scan line converted to circles.
Polygon filling Method :
Advantages:
• Scan fill algorithm fills the polygon in the same order as rendering.
• It takes advantage of coherence thus, a fast algorithm.
Disadvantages:
• The intensity of the pixels is unequal.
• Staircase-like appearance when scan line converted to circles.
2D Transformations :
Types of Transformations:
• Translation
• Scaling
• Rotating
• Reflection
• Shearing
Translation :
It is the straight line movement of an object from one position to another is called
Translation. Here the object is positioned from one coordinate location to another.
Translation of point:
To translate a point from coordinate position (x, y) to another (x1 y1), we add algebraically
the translation distances Tx and Ty to original coordinate. The translation pair (Tx,Ty) is
called as shift vector.
x1=x+Tx
y1=y+Ty
Translation :
• It is used to alter or change the size of objects. The change is done using scaling
factors. There are two scaling factors, i.e. Sx in x direction Sy in y-direction. If the
original position is x and y. Scaling factors are Sx and Sy then the value of coordinates
after scaling will be x1 and y1.
• If the picture to be enlarged to twice its original size then Sx = Sy =2. If Sxand Sy are
not equal then scaling will occur but it will elongate or distort the picture.
Scaling :
• If scaling factors are less than one, then the size of the object will be reduced. If
scaling factors are higher than one, then the size of the object will be enlarged.
• If Sx and Sy are equal it is also called as Uniform Scaling. If not equal then called as
Differential Scaling. If scaling factors with values less than one will move the object
closer to coordinate origin, while a value higher than one will move coordinate
position farther from origin.
Scaling :
Enlargement: If T1= ,If (x1 y1)is original position and T1is translation vector then
(x2 y2) are coordinated after scaling
• Straight Line: Straight Line is rotated by the endpoints with the same angle and
redrawing the line between new endpoints.
• Polygon: Polygon is rotated by shifting every vertex using the same rotational angle.
• Curved Lines: Curved Lines are rotated by repositioning of all points and drawing
of the curve at new positions.
It is a transformation which produces a mirror image of an object. The mirror image can be
either about x-axis or y-axis. The object is rotated by180°.
Types of Reflection:
1. Reflection about the x-axis
2. Reflection about the y-axis
3. Reflection about an axis perpendicular to xy plane and passing through the origin
4. Reflection about line y=x
Reflection :
Reflection about x-axis: The object can be
reflected about x-axis with the help of the
following matrix
Reflection about line y=x: The object may be reflected about line y = x with the help of
following transformation matrix
It is transformation which changes the shape of object. The sliding of layers of object occur.
The shear can be in one direction or in two directions.
Shearing in the X-direction: In this horizontal shearing sliding of layers occur. The
homogeneous matrix for shearing in the x-direction is shown below:
Shearing in the Y-direction: Here shearing is done by sliding along vertical or y-axis.
Shearing :
Shearing in X-Y directions: Here layers will be slided in both x as well as y direction. The
sliding will be in horizontal as well as vertical direction. The shape of the object will be
distorted. The matrix of shear in both directions is given by:
Shearing :
3D Transformation :
Types of Transformations:
• Translation
• Scaling
• Rotating
Translation :
It is the movement of an object from one position to another position. Translation is done
using translation vectors. There are three vectors in 3D instead of two. These vectors are in
x, y, and z directions. Translation in the x-direction is represented using Tx. The translation
is y-direction is represented using Ty. The translation in the z- direction is represented using
Tz.
If P is a point having co-ordinates in three directions (x, y, z) is translated, then after
translation its coordinates will be (x1 y1 z1) after translation. Tx Ty Tz are translation
vectors in x, y, and z directions respectively.
x1=x+ Tx
y1=y+Ty
z1=z+ Tz
Translation :
Scaling is used to change the size of an object. The size can be increased or decreased. The
scaling three factors are required Sx Sy and Sz.
Sx=Scaling factor in x- direction
Matrix for Scaling
Sy=Scaling factor in y-direction
Sz=Scaling factor in z-direction
Scaling :
It is change in the shape of the object. It is also called as deformation. Change can be in
the x -direction or y -direction or both directions in case of 2D. If shear occurs in both
directions, the object will be distorted. But in 3D shear can occur in three directions.
Types of Projections:
1.Parallel projections
2.Perspective projections
Projections:
Centre of Projection:
It is an arbitrary point from where the lines are drawn on each point of an object.
• If cop is located at a finite point in 3D space , Perspective projection is the result
• If the cop is located at infinity, all the lines are parallel and the result is a parallel
projection.
Projections:
Parallel Projection:
• A parallel projection is formed by extending parallel lines from each vertex of object
until they intersect plane of screen.
• Parallel projection transforms object to the view plane along parallel lines. A projection is
said to be parallel, if center of projection is at an infinite distance from the projected
plane.
• A parallel projection preserves relative proportion of objects, accurate views of the
various sides of an object are obtained with a parallel projection.
• The projection lines are parallel to each other and extended from the object and intersect
the view plane.
Projections:
Parallel projection is divided into two parts and these two parts sub divided into many.
Orthographic Projections:
• In orthographic projection the direction of projection is normal to the projection of the
plane. In orthographic lines are parallel to each other making an angle 90 with view
plane.
• Orthographic parallel projections are done by projecting points along parallel lines that
are perpendicular to the projection line.
• Orthographic projections are most often used to procedure the front, side, and top views
of an object are called evaluations.
Projections:
• Engineering and architectural drawings commonly employ these orthographic
projections. Transformation equations for an orthographic parallel projection as straight
forward.
• Some special orthographic parallel projections involve plan view, side elevations. We can
also perform orthographic projections that display more than one phase of an object, such
views are called monometric orthographic projections.
Oblique Projections:
• Oblique projections are obtained by projectors along parallel lines that are not
perpendicular to the projection plane.
Projections:
• An oblique projection shows the front and top surfaces that include the three dimensions
of height, width and depth.
• The front or principal surface of an object is parallel to the plane of projection. Effective
in pictorial representation.
Isometric Projections: Orthographic projections that show more than one side of an
object are called axonometric orthographic projections. The most common axonometric
projection is an isometric projection. In this projection parallelism of lines are preserved but
angles are not preserved.
Dimetric projections: In these two projectors have equal angles with respect to two
principal axis.
Trimetric projections: The direction of projection makes unequal angle with their
principal axis.
Projections:
Cavalier Projections:
All lines perpendicular to the
projection plane are projected
with no change in length. If the
projected line making an angle
45 degrees with the projected
plane, as a result the line of the
object length will not change.
Projections:
Cabinet Projections:
All lines perpendicular to the projection
plane are projected to one half of their
length. These gives a realistic appearance
of object. It makes 63.4 degrees angle
with the projection plane. Here lines
perpendicular to the viewing surface are
projected at half their actual length.
Projections:
Perspective Projections:
• A perspective projection is the one produced by straight lines radiating from a common
point and passing through point on the sphere to the plane of projection.
• Perspective projection is a geometric technique used to produce a three dimensional
graphic image on a plane, corresponding to what person sees.
• Any set of parallel lines of object that are not parallel to the projection plane are projected
into converging lines. A different set of parallel lines will have a separate vanishing point.
• Coordinate positions are transferred to the view plane along lines that converge to a point
called projection reference point.
Projections:
Perspective Projections:
• The distance and angles are not preserved and parallel lines do not remain parallel.
Instead, they all converge at a single point called center of projection there are 3 types of
perspective projections.
• Two characteristic of perspective are vanishing point and perspective force shortening.
Due to fore shortening objects and lengths appear smaller from the center of projections.
The projections are not parallel and we specify a center of projection cop.
Projections:
One point perspective projections: In this, principal axis has a finite vanishing
point. Perspective projection is simple to draw.
Projections:
Three point perspective projections: All the three principal axes have finite
vanishing point. Perspective projection is most difficult to draw.