Upload
vandieu
View
226
Download
1
Embed Size (px)
Citation preview
Computer Graphics: Graphics Output Primitives
Circle Drawing, and Fill Area Polygons
By: A. H. Abdul Hafez
March 8, 2017 1 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU
Outlines
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 2
1. Circle drawing algorithm
2. Frame buffer values
3. Fill area polygon
4. Plane equation and inside-outside test
5. Character primitives
6. End
Circle generation algorithm
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 3
A circle is defined as the set of points that are all at a given
distance r from a center position (xc, yc).
Symmetry of a circle.
Calculation of a circle point
(x, y) in one octant yields
the circle points shown for
the other seven octants.
Midpoint circle algorithm
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 4
To apply the midpoint method, we define a
circle residual function as
Our decision parameter is the circle function
evaluated at the midpoint between these two
pixels
Midpoint circle algorithm
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 5
The initial decision parameter is obtained by evaluating the circle
function at the start position (x0,y0)=(0,r):
If pk < 0, this midpoint is inside the circle and the pixel on scan line
yk is closer to the circle boundary. Otherwise, the mid position is
outside or on the circle boundary, and we select the pixel on scan
line yk - 1.
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 6
Example on Midpoint circle algorithm
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 7
Example on Midpoint circle algorithm
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 8
Example on Midpoint circle algorithm
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 9
Fill-area
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 10
Fill area is an area that is filled with some solid color or pattern.
Fill areas are used to describe surfaces of solid objects, but they are
also useful in a variety of other applications.
Fill regions are usually planar surfaces, mainly polygons. But, in
general, there are many possible shapes for a region in a picture
that we might wish to fill with some color option.
Solid-color fill areas specified with various boundaries
(a) A circular fill region
(b) A fill area bounded by a closed plotlines
(c) A filled area specified with an irregular curved boundary.
Classification of Polygons
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 11
A polygon is a plane figure specified by a set of three or more
coordinate positions, called vertices, that are connected in sequence
by straight-line segments, called the edges or sides of the polygon.
An interior angle of a polygon is an angle inside the polygon
boundary that is formed by two adjacent edges. If all interior angles
of a polygon are less than or equal to 180°, the polygon is convex.
A polygon that is not convex is called a concave polygon.
Convex and concave polygons
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 12
A concave polygon has at least one interior angle greater than 180.
Also, the extension of some edges of a concave polygon will
intersect other edges.
Some pair of interior points will produce a line segment that
intersects the polygon boundary.
Convex and concave polygons
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 13
Algorithmic:
1. If we set up a vector for each
polygon edge, then we can use
the cross product of adjacent
edges to test for concavity.
2. All such vector products will be
of the same sign (positive or
negative) for a convex polygon.
3. Therefore, if some cross products
yield a positive value and some a
negative value, we have a
concave polygon. Qi = (Vi – Vi-1)x(Vi+1 - Vi)
Qi. Qi+1 >0 for all i, then polygon is convex
Splitting a
concave polygon
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 14
Splitting a polygon
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 15
Polygons tables
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 16
As information for each polygon is input, the data are placed into
tables that are to be used in the subsequent processing, display, and
manipulation of the objects in the scene.
These polygon data tables can be organized into two groups:
Geometric tables and attribute tables.
1. Geometric data tables contain vertex coordinates and parameters to identify
the spatial orientation of the polygon surfaces.
2. Attribute information for an object includes parameters specifying the
degree of transparency of the object, its surface reflectivity, and texture
characteristics.
Polygons tables
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 17
Geometric data for the objects
in a scene are arranged
conveniently in three lists:
1. a vertex table,
2. an edge table, and
3. a surface-facet table.
The edge table contains
pointers back into the vertex
table to identify the vertices for
each polygon edge.
And the surface-facet table
contains pointers back into the
edge table to identify the edges
for each polygon.
Plane Equations
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 18
Each polygon in a scene is contained within a plane of infinite
extent. The general equation of a plane is
Solution with 3 points
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 19
Front and back faces
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 20
The normal vector N for a plane described with the equation Ax + By +Cz + D = 0 is perpendicular to the plane and has Cartesian components (A, B, C) .
The end of the Lecture
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 21
Thanks for your time
Questions are welcome