computer graphics - bilgisayar mühendisliği bölümü |...
TRANSCRIPT
![Page 1: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/1.jpg)
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
![Page 2: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/2.jpg)
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
![Page 3: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/3.jpg)
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.
![Page 4: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/4.jpg)
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
![Page 5: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/5.jpg)
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.
![Page 6: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/6.jpg)
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 6
![Page 7: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/7.jpg)
Example on Midpoint circle algorithm
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 7
![Page 8: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/8.jpg)
Example on Midpoint circle algorithm
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 8
![Page 9: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/9.jpg)
Example on Midpoint circle algorithm
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 9
![Page 10: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/10.jpg)
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.
![Page 11: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/11.jpg)
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.
![Page 12: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/12.jpg)
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.
![Page 13: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/13.jpg)
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
![Page 14: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/14.jpg)
Splitting a
concave polygon
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 14
![Page 15: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/15.jpg)
Splitting a polygon
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 15
![Page 16: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/16.jpg)
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.
![Page 17: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/17.jpg)
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.
![Page 18: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/18.jpg)
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
![Page 19: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/19.jpg)
Solution with 3 points
March 8, 2017 CG, by Dr. A.H. Abdul Hafez, CE Dept. HKU 19
![Page 20: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/20.jpg)
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) .
![Page 21: Computer Graphics - Bilgisayar Mühendisliği Bölümü | …compe.hku.edu.tr/Dosyalar/COME-306--Bilgisayar...Computer Graphics: Graphics Output Primitives Circle Drawing, and Fill](https://reader030.vdocument.in/reader030/viewer/2022021511/5ad6a3d17f8b9a6d708e6c14/html5/thumbnails/21.jpg)
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