Output Primitives
Output Primitives
FACULTY OF COMMERCE
MIDLANDS STATE UNIVERSITY
FACULTY OF BUSINESS SCIENCES
DEPARTMENT OF INFORMATION AND MARKETING SCIENCES
INFO411- COMPUTER GRAPHICS
Lecturer: R. Gumbo
OUTPUT PRIMITVES
Presentation Focus
Output Primitives
The Basic attributes of a straight line segment are its type, its width, and its color. In some
graphics packages, lines can also be displayed using selected pen or brush options
Line Type
Line Width
Pen and Brush Options
Line Color
Line Drawing Algorithms
Step 2: m= (y2-y1)/(x2-x1) which translates to (7-1)/(8-1) which equals 6/7 and definitely a case of m<1
Step 3: As m<1 therefore x is increased and y is calculated. This means we increment x as x1+1 and
calculate y1 as y1=y1+m. The points generated will be x1=x1+1 and y1=1+(6/7) =1.9=> approx. 2 so
x1=2 and y1=~2 as below
1 2 2 2,2
2 3 2+(6/7)=2.9 3,3
3 4 2.9+0.9=3.8 4,4
4 5 3.8+0.9=4.7 5;5
The algorithm will stop here
5 6 4.7+0.9=5.6 6,6
since the y value has reached 7 6 7 5.6+0.9=6.5 7,7
Advantages and disadvantages of DDA
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:
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.
Bresenham’s Line Drawing Algorithm
Bresenham Line Algorithm is an optimistic & incremental scan conversion Line Drawing Algorithm that
calculates all intermediate points over the interval between start and endpoints.
It is implemented entirely with integer numbers and the integer arithmetic. It only uses addition and
subtraction and avoids heavy operations like multiplication and division.
The idea of Bresenham’s algorithm is to avoid floating-point multiplication and addition to compute mx + c,
and then computing the round value of (mx + c) in every step.
Bresenham’s Line Drawing Algorithm determines the points of an n-dimensional raster that should be
selected in order to form a close approximation to a straight line between two points.
Bresenham’s Line Drawing Algorithm cont’
2. DDA Algorithms uses multiplication & division its operation 2.Bresenham's Line Algorithm uses only subtraction and addition its
operation
3. DDA Algorithm is slowly than Bresenham's Line Algorithm in 3. Bresenham's Algorithm is faster than DDA Algorithm in line
line drawing because it uses real arithmetic (Floating Point because it involves only addition & subtraction in its calculation and
operation) uses only integer arithmetic.
4. DDA Algorithm is not accurate and efficient as Bresenham's Line 4. Bresenham's Line Algorithm is more accurate and efficient at
Algorithm. DDA Algorithm.
5.DDA Algorithm can draw circle and curves but are not accurate as 5. Bresenham's Line Algorithm can draw circle and curves with more
Bresenham's Line Algorithm accurate than DDA Algorithm.
Circle drawing algorithms
A Circle is defined as the set of points that are all at a given distance r from a center
position (xc, yc).
Types of circle drawing algorithms
Bresenham’’s circle algorithm
Midpoint Circle Algorithm
Bresenham’s circle algorithm
Bresenham’’s circle algorithm avoids these square root calculations by comparing the
squares of the pixel separation distances. Points are generated from 90° to 45°, moves will
be made only in the +x & -y directions.
The best approximation of the true circle will be described by those pixels in the raster that
falls the least distance from the true circle.
In this approach is to test the halfway position between two pixels to determine if this
midpoint is inside or outside the circle boundary.
Steps to Bresenham’s circle algorithm
Step1: Start Algorithm
Step2: Declare p, q, x, y, r, d variables
p, q are coordinates of the center of the circle
r is the radius of the circle
Step3: Enter the value of r
Step4: Calculate d = 3 - 2r
Step5: Initialize x=0
&nbsy= r
Step6: Check if the whole circle is scan converted
If x > = y
Stop
Step7: Plot eight points by using concepts of eight-way symmetry. The center is at (p, q). Current active pixel is (x, y).
putpixel (x+p, y+q)
putpixel (y+p, x+q)
putpixel (-y+p, x+q)
putpixel (-x+p, y+q)
putpixel (-x+p, -y+q)
putpixel (-y+p, -x+q)
putpixel (y+p, -x+q)
putpixel (x+p, -y-q)
Steps to Bresenham’s circle algorithm Cont’