






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A detailed overview of the bresenham's circle and line drawing algorithms, which are widely used in computer graphics for efficiently generating circles and lines on a raster display. The step-by-step implementation of these algorithms, including the mathematical principles behind them, the key variables and calculations involved, and the output generation process. It also highlights the advantages of bresenham's algorithms over other methods, such as their faster execution and higher accuracy. The learning outcomes section further emphasizes the key takeaways, such as the use of integer arithmetic, the ability to draw more accurate circles and curves, and the overall efficiency of these algorithms compared to alternatives like the digital differential analyzer (dda) algorithm. The document serves as a comprehensive resource for students and professionals interested in understanding and implementing these fundamental computer graphics techniques.
Typology: Exercises
1 / 11
This page cannot be seen from the preview
Don't miss anything!
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 Enter the value of r Calculate d = 3 - 2r Initialize x= &nbsy= r Check if the whole circle is scan converted If x > = y Stop 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) Find location of next pixels to be scanned If d < 0 then d = d + 4x + 6 increment x = x + 1 If d ≥ 0 then d = d + 4 (x - y) + 10 increment x = x + 1 decrement y = y – 1
C. Steps For Experiment/ Practical #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #include <math.h> void EightWaySymmetricPlot(int xc,int yc,int x,int y) { putpixel(x+xc,y+yc,RED); putpixel(x+xc,-y+yc,YELLOW); putpixel(-x+xc,-y+yc,GREEN); putpixel(-x+xc,y+yc,YELLOW); putpixel(y+xc,x+yc,12); putpixel(y+xc,-x+yc,14); putpixel(-y+xc,-x+yc,15); putpixel(-y+xc,x+yc,6); } void BresenhamCircle(int xc,int yc,int r) { int x=0,y=r,d=3-(2r); EightWaySymmetricPlot(xc,yc,x,y); while(x<=y) { if(d<=0) { d=d+(4x)+6; } else { d=d+(4x)-(4y)+10; y=y-1; } x=x+1; EightWaySymmetricPlot(xc,yc,x,y); } }
Learning outcomes (What I have learnt):
1. It is faster as compared to DDA (Digital Differential Analyzer) because it does not involve floating point calculations like DDA Algorithm. 2. Bresenham's Line Algorithm use fixed point, i.e., Integer Arithmetic... 3. Bresenham's Line Algorithm can draw circle and curves with more accurate than DDA Algorithm. E. Steps of Experiment
F. Steps For Experiment/ Practical #include <graphics.h> #include <stdio.h> #include <math.h> #include <dos.h> void main( ) { float x,y,x1,y1,x2,y2,dx,dy,step; int i,gd=DETECT,gm; initgraph(&gd,&gm,"c:\turboc3\bgi"); printf("Enter the value of x1 and y1 : "); scanf("%f%f",&x1,&y1); printf("Enter the value of x2 and y2: "); scanf("%f%f",&x2,&y2); dx=abs(x2-x1); dy=abs(y2-y1); if(dx>=dy) step=dx; else step=dy; dx=dx/step; dy=dy/step; x=x1; y=y1; i=1; while(i<=step) { putpixel(x,y,5); x=x+dx; y=y+dy; i=i+1; delay(100); }
Consider (x, y) as starting point and xendas maximum possible value of x. If dx < 0 Then x = x 2 y = y 2 xend=x 1 If dx > 0 Then x = x 1 y = y 1 xend=x 2 Generate point at (x,y)coordinates. Check if whole line is generated. If x > = xend Stop. Calculate co-ordinates of the next pixel If d < 0 Then d = d + i 1 If d ≥ 0 Then d = d + i 2 Increment y = y + 1 Increment x = x + 1 Draw a point of latest (x, y) coordinates I. Steps For Experiment/ Practical
1. It is faster as compared to DDA (Digital Differential Analyzer) because it does not involve floating point calculations like DDA Algorithm. 2. Bresenham's Line Algorithm use fixed point, i.e., Integer Arithmetic... 3. Bresenham's Line Algorithm can draw circle and curves with more accurate than DDA Algorithm.