cg lab-record-full

of 46
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
Computer graphics
  Expt no : 1aDate : Drawing line using Bresenham algorithm Aim:  To draw line using bresenham algorithm in c. Algorithm: 1.Input two line endpoints 2.Obtain starting value for the decision parameter asP 0 =2∆!∆ #.If p $  %0 the ne t point to plot is & $  '1( $  ) and p $'1 =p $  '2∆ else ne t point to plot is & $  '1( $  '1) and  p $'1 =p $  '2∆!2∆ *.+epeat step # ∆ times. Coding: ,include%stdio.h-,include%conio.h-,include%math.h-,include%graphics.h-main&)int gd=/TT(gmint a( b(a(bint d (d(3(4(3end(p(binitgraph&5gd(5gm(6c788tc88bgi6) printf&69T+ T:O ;<T 9/ POI9T6)scanf&6>d>d6(5 a(5a) printf&69T+ T:O +I?@T 9/ POI9T 6)scanf&6>d>d6(5 b(5b)d =abs& a! b)d=abs&a!b) p=2Ad!d if& a- b)3= b4=b3end= aB else3= a4=a3end= bB putpi el&3(4(b)while&3%3end)  3=3'1if&p%0) p=p'2AdBelse4=4'1 p=p'2A&d!d )B putpi el&3(4(b)Bgetch&)return&0)B OUTPUT: nter two left endpoints7100200nter two right endpoints7#00*00 RESUT:  The line was drawn using  bresenham algorithm successfull.   pt no 7 1b/ate 7 Drawing !ir!le using Bresenham algorithm Aim:  To draw circle using bresenham algorithm in c. Algorithm: 1.Input radius r and circle center& c(c)2.calculate the initial value of the decision parameter as P0=CD*!r #.If p$%0( the ne t point along the circle is calculated as p $'1 =p $  '2 $'1 '1 otherwise calculate using  p $'1 =p $  '2 $'1 '1!2 $'1 *.+epeat step # until -=. COD #$: ,include 6stdio.h6 ,include 6conio.h6 ,include 6math.h6 ,include 6graphics.h6 main&)  int gd=/TT(gm int center(center(radius int p( ( initgraph&5gd(5gm(6c788tc88bgi6) =0  printf&6nter The +adius Ealue78n6) scanf&6>d6(5radius) =radius  printf&6nter The center and center Ealues78n6) scanf&6>d>d6(5 center(5center)  plotpoints& center(center( ()  p=1!radius while& %)  if&p%0) = '1 else  = '1 =!1 B if&p%0)  p=p'2A '1 else  p=p'2A& !)'1  plotpoints& center(center( () B  getch&) return&0) B int plotpoints&int center(int center(int (int )   putpi el& center' (center'(1)  putpi el& center! (center'(1)  putpi el& center' (center!(1)  putpi el& center! (center!(1)  putpi el& center'(center' (1)  putpi el& center!(center' (1)  putpi el& center'(center! (1) B OUTPUT: nter The +adius Ealue7100nter The center and center Ealues7100200 RESUT:  The circle was drawn using  bresenham algorithm successfull.
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks