Arithmetic
Operations
Speed
Accuracy &
Efficiency
Drawing
Round Off
DDALineDrawingAlgorithm vs BresenhamsLineDrawingAlgorithm
uses floating points
Usesmultiplication anddivision inits
operations.
slowly than Bresenhams algorithm
not as accurate and efficient
DDAalgorithm can drawcircles and curves
but that are not as accurate as Bresenhams
algorithm.
DDA algorithm round off the coordinates to
Integer points
Usesonlysubtractionandaddition
in its operations.
faster than DDA
more efficient &much accurate
Draw circles and curves with much
more accuracy than DDA algorithm.
Bresenhams algorithm docs
not round off but takes theCircle generating algorithm:
Symmetry of circle:
Acircle is a geometric figure which is round, and can be divided into 360 degrees. A circle is a
symmetrical figure which follows 8-way symmetry.
8 Way symmetry: Any circle follows 8-way symmetry. This means that for every point (x,y) 8
points can be plotted. These (x,y), (yx), (yx), (x,y), x9), Cy,-%), (VX), (-9)-
Drawing a circle: To drawa circle we need two things, the coordinates of the centre and the radius
of the circle.
Here r is the radius of the circle. If the circle has origin (0,0) as its centre then the above equation
can be reduced to x2+y2=r2
Bresenham’s Algorithm
We cannot display a continuous are on the raster display. Instead, we have to choose the nearest
pixel position to complete the arc.
From the following illustration, you can see that we have put the pixel at (X, Y) location and now
need to decide where to put the next pixel - at N (X+1, Y) or at S (X+1, ¥-1).swag)
This can be decided by the decision parameter d.
Ifd <=0, then N(X+1, ¥) is tobe chosen as next pixel.
Ifd>o, then S(X+1, Y-1) is to be chosen as the next pixel.
Breshenham’s Algorithm For Circle Drawing,
pont
. Read the radius ofcirele.
. Calculate initial decision parameter di=g-2r
. x=0 and y=r [initialize the starting point]
Do
. Plot(xy)//plot point(x,y) and other 7pointsinall octant
if(di
#include
#include
#indude
sinclude
void bressn(int,int,int);
void plot(int,int,int,int);
void plot(int xc,int yc,int x,int y)
f
putpixel(xc+x,ye+y, WHITE);
putpixel(xe-x,yety,RED);
putpixel(xe-x,ye-y,GREEN);
putpixel(xe+x,ye-y,YELLOW);
putpixel(xe+y,ye+x, WHITE);
putpixel(xc-y,ye+x,GREEN);
putpixel(xc-y,ye-x, YELLOW);
putpixel(xc+y,ye-x,RED);
}
void bressn(int r,int xc,int yc)
{
int dx
de=g-(2"1);
10/28while(x