Unit 1 Primitive Section[1]
Unit 1 Primitive Section[1]
Primitives
Primitives: Basic Graphics
Primitives
I. Scan conversion a Line.
Bresenham’s Algorithm.
Basic concept of Line drawing
Direct use of Line Equation
Step6: Calculate m =
Advantages:
It is a faster method than method of using direct use of
line equation.
This method does not use multiplication theorem.
It allows us to detect the change in the value of x and y, so
plotting of same point twice is not possible.
This method gives overflow indication when a point is
repositioned.
It is an easy method because each step involves just two
additions.
Disadvantages of DDA
Disadvantages:
It involves floating point additions rounding off is done.
Accumulations of round off error cause accumulation of
error.
Rounding off operations and floating point operations
consumes a lot of time.
It is more suitable for generating line using the software.
But it is less suited for hardware implementation.
Example: If a line is drawn from (2, 3) to (6, 15) with use of DDA. How
many points will needed to generate such line?
Solution: P1 (2,3) P11 (6,15)
x1=2
y1=3
x2= 6
y2=15
dx = 6 - 2 = 4
dy = 15 - 3 = 12
m=
For calculating next value of x takes x = x + 1/m
Problems of DDA
1 1 d+I2=1+(-6)=-5
2 2 d+I1=-5+8=3
3 2 d+I2=3+(-6)=-3
4 3 d+I1=-3+8=5
5 3 d+I2=5+(-6)=-1
6 4 d+I1=-1+8=7
7 4 d+I2=7+(-6)=1
8 5
Difference Between DDA and
Bresenham’s Line Algorithms
DDA Algorithm Bresenham's Line Algorithm
2. DDA Algorithms uses multiplication & 2.Bresenham's Line Algorithm uses only
division its operation subtraction and addition its operation
5.DDA Algorithm can draw circle and 5. Bresenham's Line Algorithm can
curves but are not accurate as draw circle and curves with more
Bresenham's Line Algorithm accurate than DDA Algorithm.
Antialiasing of Lines
In the line drawing algorithm, we have seen that all rasterized locations
do not match with the true line and we have to select the optimum
raster locations to represent a straight line.
Increasing resolution:
Unweighted area sampling: The intensity of pixel is proportional to the
amount of line area occupied by the pixel. This technique produces
noticeably better results than does setting pixels either to full intensity or
to zero intensity.
Weighted area sampling: in weighted area sampling equal areas
contribute unequally i.e. a small area closer to the pixel center has
greater intensity than does one at a greater distance. Thus, the intensity
of the pixel is dependent on the line area occupied and the distance of
area from the pixel’s center.
Displaying Polylines
Implementation of a polyline procedure is accomplished by invoking a
line-drawing routine n-1 times to display the line connecting the n
endpoints.
Each successive call passes the coordinate pair needed to plot the next
line section, where the first endpoint of each coordinate pair is the last
endpoint of the previous section.
Once the color values for pixel positions along the first line segment have
been set in the frame buffer, we process subsequent line segments
starting with the next pixel position following the first endpoint for that
segment.
In this way, we can avoid setting the color of some endpoints twice.
Polyline representation
Parallel Line Algorithms
Unit steps would then be taken in the positive y direction up to the last
position selected in region 1.
MidPoint Ellipse drawing
algorithm…
Lab4 Assignment for the Lab: write
an OpenGL program for displaying
the following diagram:
Scan-conversion of conic
section
Area Filling
Rasterizing a Polygon.
A polyline is a chain of connected line segments. It is
specified by giving the vertices or nodes P0,P1,P2,… and
so on.
The first vertex is called the initial or starting point and
the last vertex is called the final or terminal point.
When starting point and terminal point of any polyline is
same, i.e. when polyline is closed then it is called
polygon.
Scan-converting a Polygon
Disadvantage:
Very slow algorithm
May be fail for large polygons
Initial pixel required more knowledge about surrounding pixels.
Flood fill algorithm…
Scan Line Polygon Fill
Algorithm
This algorithm lines interior points of a polygon on the
scan line and these points are done on or off according
to requirement.
The polygon is filled with various colors by coloring
various pixels.
First of all, scanning is done. Scanning is done using
raster scanning concept on display device.
The beam starts scanning from the top left corner of
the screen and goes toward the bottom right corner as
the endpoint.
The algorithms find points of
intersection of the line with polygon
while moving from left to right and
top to bottom.
The various points of intersection are
stored in the frame buffer.
The intensities of such points is keep
high.
Concept of coherence property is
used. According to this property if a
pixel is inside the polygon, then its
next pixel will be inside the polygon.
Side effects of Scan Conversion:
Staircase or Jagged: Staircase like appearance is seen
while the scan was converting line or circle.