SlideShare a Scribd company logo
1 of 15
Scan Converting a Circle

A circle is a symmetric figure. Any circle
  generating algorithm can take advantage of
  the circle’s symmetry to plot eight points for
  each value that the algorithm calculates.
  Eight way symmetry is used by reflecting
  each calculated point around each 45 º axis.
y
         -y,x       y,x

-x,y                        x,y


                                     x

-x,-y                         x,-y


                     y,-x
        -y,-x
Scan Converting a Circle using Polynomial
method:-
This method defines a circle with second
order polynomial equation
            y2 = r2 – x2
where x, y = x & y coordinates, r = radius
With this method, each x coordinate in the
sector, from 90º to 45º, is found by stepping
x from 0 to r / 2 , and each y coordinate is found by
evaluating r2 – x2 for each step of x.
This is a very inefficient method, however,
  because for each point both x & r must be
  squared and subtracted from each other;
  then the square root of the result must be
  found.               y
                               P(x, r2 – x2 )
                   y   r
                                     x
                   0       x
Scan Convert a Circle using trigonometric
method:-
This second method of defining a circle uses
  functions : x = r cos θ, y = r sin θ
                   y
                             P(r cos θ,r sin θ)

                                    r sin θ
                       θ
                                     x
                        r cos θ
θ = current angle, r = circle radius
 By this method θ is stepped from θ to π /4
& each value of x & y is calculated.
Computation of values of sin θ & cos θ are
very time consuming
Bresenham’s Circle Algorithm
Working: If the eight-way symmetry of a circle is
used to generate a circle, points will have to be
generated through 45º angle. And, if points are
generated from 90º to 45º, moves will be made only
in the +x and –y directions.
If points are generated from 90º to 45º each new
     point closest to the true circle can be found by
     taking either of two actions:
(1) Move in the x direction one unit or
(2) Move in the x direction 1 unit & -ve y direction
     1 unit.
y
            T    (xi+1,yi)
  yi
                 (xi+1,yi-1)
yi -1
             S



                 r




        xi xi + 1              x
Assume that (xi, yi) are the coordinates of the
last scan-converted pixel upon entering step i.
Let the distance from the origin to pixel T
   squared minus the distance to the true
   circle squared = D(T) = t2 – r2.
And let the distance from the origin to pixel S
   squared minus the distance to the true
   circle squared = D(S) = s2 – r2.
Coordinates of T are (xi +1, yi)
                S are (xi +1, yi – 1)
Following expressions can be developed:
D(T) = (xi + 1)2 + yi2 – r2
D(S) = (xi + 1)2 + (yi – 1)2 – r2
          This function D provides a relative
measurement of the distance from the center
of a pixel to the true circle. Since D(T) is
always +ve (T is outside the circle) & D(S)
will always be –ve (S is inside the true circle),
a decision variable di can be defined as:
di = D(T) – (-D(S)) = D(T) + D(S)
Therefore,
 di = 2(xi + 1)2 + yi2 + (yi – 1)2 – 2r2
When di<0, we have |D(T)|<|D(S)| and pixel
     T
is chosen.
When di>0, we have |D(T)|>|D(S)| and pixel S
is selected. Decision variable for next step:
di+1 = 2(xi+1 + 1)2 + yi+12 + (y i+1 – 1)2 – 2r2
Hence,
di+1 – di = 2(xi+1 + 1)2 + yi+12 + (yi+1 – 1)2 -
            2(xi + 1)2 - yi2 - (yi – 1)2
Since xi+1 = xi + 1, we have
di+1 = di + 4xi + 2(yi+12 - yi2) – 2(yi+1 – yi) + 6
If T is chosen pixel (meaning that di < 0)
 then yi+1 = yi and so di+1 = di + 4xi + 6
If S is chosen (meaning that di > 0) then y i+1
 = yi –1 and so di+1 = di + 4(xi-yi) + 10
Hence we have
di+1 = di + 4xi + 6        if di < 0
       di + 4(xi-yi) + 10     if di > 0
Finally, we set(0,r) to the starting pixel
   coordinates and compute d1 from the
   original definition of di:
    x = 0, y = r
d1= 2(0 + 1)2 + r2 + (r-1)2 – 2r2
  = 3 – 2r
Algorithm:
For generating all the pixel coordinates in the
90º to 45º octant that are needed when scan-
converting a circle of radius r.
(i) int x = 0, y = r, d = 3-2r
(ii) while (x <= y)
     {
     setpixel(x,y)
      if (d < 0)
      d = d + 4x + 6
else
    {
     d = d + 4(x - y) + 10
     y--
     }
    x++
}

More Related Content

What's hot

Cyrus beck line clipping algorithm
Cyrus beck line clipping algorithmCyrus beck line clipping algorithm
Cyrus beck line clipping algorithmPooja Dixit
 
Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithmPooja Dixit
 
Polygon Fill
Polygon FillPolygon Fill
Polygon Fillwahab13
 
Composite transformations
Composite transformationsComposite transformations
Composite transformationsMohd Arif
 
Back face detection
Back face detectionBack face detection
Back face detectionPooja Dixit
 
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithmMani Kanth
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformationSelvakumar Gna
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsDrishti Bhalla
 
3D Transformation in Computer Graphics
3D Transformation in Computer Graphics3D Transformation in Computer Graphics
3D Transformation in Computer Graphicssabbirantor
 
Output primitives computer graphics c version
Output primitives   computer graphics c versionOutput primitives   computer graphics c version
Output primitives computer graphics c versionMarwa Al-Rikaby
 
3 d geometric transformations
3 d geometric transformations3 d geometric transformations
3 d geometric transformationsMohd Arif
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer GraphicsLaxman Puri
 
Fill area algorithms
Fill area algorithmsFill area algorithms
Fill area algorithmsKumar
 
2 d geometric transformations
2 d geometric transformations2 d geometric transformations
2 d geometric transformationsMohd Arif
 
The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmMani Kanth
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversionMohd Arif
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.Mohd Arif
 
Scan line method
Scan line methodScan line method
Scan line methodPooja Dixit
 

What's hot (20)

Cyrus beck line clipping algorithm
Cyrus beck line clipping algorithmCyrus beck line clipping algorithm
Cyrus beck line clipping algorithm
 
Bresenham's line algorithm
Bresenham's line algorithmBresenham's line algorithm
Bresenham's line algorithm
 
Polygon Fill
Polygon FillPolygon Fill
Polygon Fill
 
Composite transformations
Composite transformationsComposite transformations
Composite transformations
 
Back face detection
Back face detectionBack face detection
Back face detection
 
Seed filling algorithm
Seed filling algorithmSeed filling algorithm
Seed filling algorithm
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformation
 
Dda algorithm
Dda algorithmDda algorithm
Dda algorithm
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
 
3D Transformation in Computer Graphics
3D Transformation in Computer Graphics3D Transformation in Computer Graphics
3D Transformation in Computer Graphics
 
Output primitives computer graphics c version
Output primitives   computer graphics c versionOutput primitives   computer graphics c version
Output primitives computer graphics c version
 
3 d geometric transformations
3 d geometric transformations3 d geometric transformations
3 d geometric transformations
 
Polygon filling
Polygon fillingPolygon filling
Polygon filling
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
 
Fill area algorithms
Fill area algorithmsFill area algorithms
Fill area algorithms
 
2 d geometric transformations
2 d geometric transformations2 d geometric transformations
2 d geometric transformations
 
The sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithmThe sutherland hodgeman polygon clipping algorithm
The sutherland hodgeman polygon clipping algorithm
 
Intro to scan conversion
Intro to scan conversionIntro to scan conversion
Intro to scan conversion
 
Line drawing algo.
Line drawing algo.Line drawing algo.
Line drawing algo.
 
Scan line method
Scan line methodScan line method
Scan line method
 

Viewers also liked

Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...Saikrishna Tanguturu
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmMahesh Kodituwakku
 
Bressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing AlgorithmBressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing AlgorithmMrinmoy Dalal
 
Bresenham's line algo.
Bresenham's line algo.Bresenham's line algo.
Bresenham's line algo.Mohd Arif
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicsamitsarda3
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clippingMohd Arif
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmKasun Ranga Wijeweera
 
Clipping Algorithm In Computer Graphics
Clipping Algorithm In Computer GraphicsClipping Algorithm In Computer Graphics
Clipping Algorithm In Computer Graphicsstudent(MCA)
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programsAmit Kapoor
 
04. The Rendering Pipeline
04. The Rendering Pipeline04. The Rendering Pipeline
04. The Rendering PipelineAmin Babadi
 
Art Bible Dadiu May 2009
Art Bible   Dadiu May 2009Art Bible   Dadiu May 2009
Art Bible Dadiu May 2009X3r4ph
 
E-ball " Upcomming Compact PC"
E-ball " Upcomming Compact PC"E-ball " Upcomming Compact PC"
E-ball " Upcomming Compact PC"MD SALEEM QAISAR
 
Quality circle content and implementation
Quality circle content and implementationQuality circle content and implementation
Quality circle content and implementationJefin Joseph
 
Coordinate transformation
Coordinate transformationCoordinate transformation
Coordinate transformationMohd Arif
 
The MIDI Protocol - Musical Instrument Digital Interface
The MIDI Protocol - Musical Instrument Digital InterfaceThe MIDI Protocol - Musical Instrument Digital Interface
The MIDI Protocol - Musical Instrument Digital InterfaceBhaumik Bhatt
 

Viewers also liked (20)

Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
Computer Graphics - Bresenham's line drawing algorithm & Mid Point Circle alg...
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing Algorithm
 
Bressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing AlgorithmBressenham’s Midpoint Circle Drawing Algorithm
Bressenham’s Midpoint Circle Drawing Algorithm
 
Bresenham's line algo.
Bresenham's line algo.Bresenham's line algo.
Bresenham's line algo.
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing Algorithm
 
Clipping Algorithm In Computer Graphics
Clipping Algorithm In Computer GraphicsClipping Algorithm In Computer Graphics
Clipping Algorithm In Computer Graphics
 
Clipping
ClippingClipping
Clipping
 
Cg my own programs
Cg my own programsCg my own programs
Cg my own programs
 
04. The Rendering Pipeline
04. The Rendering Pipeline04. The Rendering Pipeline
04. The Rendering Pipeline
 
Art Bible Dadiu May 2009
Art Bible   Dadiu May 2009Art Bible   Dadiu May 2009
Art Bible Dadiu May 2009
 
GUI in Matlab - 2
GUI in Matlab - 2GUI in Matlab - 2
GUI in Matlab - 2
 
Windowing in apex
Windowing in apexWindowing in apex
Windowing in apex
 
E-ball " Upcomming Compact PC"
E-ball " Upcomming Compact PC"E-ball " Upcomming Compact PC"
E-ball " Upcomming Compact PC"
 
Polygon mesh
Polygon  meshPolygon  mesh
Polygon mesh
 
Quality circle content and implementation
Quality circle content and implementationQuality circle content and implementation
Quality circle content and implementation
 
Coordinate transformation
Coordinate transformationCoordinate transformation
Coordinate transformation
 
The MIDI Protocol - Musical Instrument Digital Interface
The MIDI Protocol - Musical Instrument Digital InterfaceThe MIDI Protocol - Musical Instrument Digital Interface
The MIDI Protocol - Musical Instrument Digital Interface
 
GUI in Matlab - 1
GUI in Matlab - 1GUI in Matlab - 1
GUI in Matlab - 1
 

Similar to Circle drawing algo.

Computer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.pptComputer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.pptAliZaib71
 
Lec05 circle ellipse
Lec05 circle ellipseLec05 circle ellipse
Lec05 circle ellipseMaaz Rizwan
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer GraphicsKamal Acharya
 
Bresenhamcircle derivation
Bresenhamcircle derivationBresenhamcircle derivation
Bresenhamcircle derivationMazharul Islam
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithmsMohammad Sadiq
 
chapter 3 , foley.pptxhuujjjjjjjkjmmmm. Ibibhvucufucuvivihohi
chapter 3 , foley.pptxhuujjjjjjjkjmmmm.  Ibibhvucufucuvivihohichapter 3 , foley.pptxhuujjjjjjjkjmmmm.  Ibibhvucufucuvivihohi
chapter 3 , foley.pptxhuujjjjjjjkjmmmm. Ibibhvucufucuvivihohi54MahakBansal
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D2013901097
 
mid point algorithm.pdf
mid point algorithm.pdfmid point algorithm.pdf
mid point algorithm.pdfMehulMunshi3
 
Chapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxChapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxKokebe2
 
Mid-Point Cirle Drawing Algorithm
Mid-Point Cirle Drawing AlgorithmMid-Point Cirle Drawing Algorithm
Mid-Point Cirle Drawing AlgorithmNeha Kaurav
 
9 trigonometric functions via the unit circle nat
9 trigonometric functions via the unit circle nat9 trigonometric functions via the unit circle nat
9 trigonometric functions via the unit circle natmath260
 
Rasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmRasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmKALAIRANJANI21
 

Similar to Circle drawing algo. (20)

Computer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.pptComputer_Graphics_circle_drawing_techniq.ppt
Computer_Graphics_circle_drawing_techniq.ppt
 
10994479.ppt
10994479.ppt10994479.ppt
10994479.ppt
 
Lec05 circle ellipse
Lec05 circle ellipseLec05 circle ellipse
Lec05 circle ellipse
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
Bresenhamcircle derivation
Bresenhamcircle derivationBresenhamcircle derivation
Bresenhamcircle derivation
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithms
 
chapter 3 , foley.pptxhuujjjjjjjkjmmmm. Ibibhvucufucuvivihohi
chapter 3 , foley.pptxhuujjjjjjjkjmmmm.  Ibibhvucufucuvivihohichapter 3 , foley.pptxhuujjjjjjjkjmmmm.  Ibibhvucufucuvivihohi
chapter 3 , foley.pptxhuujjjjjjjkjmmmm. Ibibhvucufucuvivihohi
 
2-D Transformations.pdf
2-D Transformations.pdf2-D Transformations.pdf
2-D Transformations.pdf
 
2.circle
2.circle2.circle
2.circle
 
Computer Graphics - transformations in 2d
Computer Graphics - transformations in 2dComputer Graphics - transformations in 2d
Computer Graphics - transformations in 2d
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D
 
mid point algorithm.pdf
mid point algorithm.pdfmid point algorithm.pdf
mid point algorithm.pdf
 
Chapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptxChapter 3 - Part 1 [Autosaved].pptx
Chapter 3 - Part 1 [Autosaved].pptx
 
Mid-Point Cirle Drawing Algorithm
Mid-Point Cirle Drawing AlgorithmMid-Point Cirle Drawing Algorithm
Mid-Point Cirle Drawing Algorithm
 
module 1.pdf
module 1.pdfmodule 1.pdf
module 1.pdf
 
D4 trigonometrypdf
D4 trigonometrypdfD4 trigonometrypdf
D4 trigonometrypdf
 
Transforms UNIt 2
Transforms UNIt 2 Transforms UNIt 2
Transforms UNIt 2
 
9 trigonometric functions via the unit circle nat
9 trigonometric functions via the unit circle nat9 trigonometric functions via the unit circle nat
9 trigonometric functions via the unit circle nat
 
Rasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmRasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithm
 

More from Mohd Arif

Bootp and dhcp
Bootp and dhcpBootp and dhcp
Bootp and dhcpMohd Arif
 
Arp and rarp
Arp and rarpArp and rarp
Arp and rarpMohd Arif
 
User datagram protocol
User datagram protocolUser datagram protocol
User datagram protocolMohd Arif
 
Project identification
Project identificationProject identification
Project identificationMohd Arif
 
Project evalaution techniques
Project evalaution techniquesProject evalaution techniques
Project evalaution techniquesMohd Arif
 
Presentation
PresentationPresentation
PresentationMohd Arif
 
Pointers in c
Pointers in cPointers in c
Pointers in cMohd Arif
 
Peer to-peer
Peer to-peerPeer to-peer
Peer to-peerMohd Arif
 
Overview of current communications systems
Overview of current communications systemsOverview of current communications systems
Overview of current communications systemsMohd Arif
 
Overall 23 11_2007_hdp
Overall 23 11_2007_hdpOverall 23 11_2007_hdp
Overall 23 11_2007_hdpMohd Arif
 
Objectives of budgeting
Objectives of budgetingObjectives of budgeting
Objectives of budgetingMohd Arif
 
Network management
Network managementNetwork management
Network managementMohd Arif
 
Networing basics
Networing basicsNetworing basics
Networing basicsMohd Arif
 
Iris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platformIris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platformMohd Arif
 
Ip sec and ssl
Ip sec and  sslIp sec and  ssl
Ip sec and sslMohd Arif
 
Ip security in i psec
Ip security in i psecIp security in i psec
Ip security in i psecMohd Arif
 
Intro to comp. hardware
Intro to comp. hardwareIntro to comp. hardware
Intro to comp. hardwareMohd Arif
 

More from Mohd Arif (20)

Bootp and dhcp
Bootp and dhcpBootp and dhcp
Bootp and dhcp
 
Arp and rarp
Arp and rarpArp and rarp
Arp and rarp
 
User datagram protocol
User datagram protocolUser datagram protocol
User datagram protocol
 
Project identification
Project identificationProject identification
Project identification
 
Project evalaution techniques
Project evalaution techniquesProject evalaution techniques
Project evalaution techniques
 
Presentation
PresentationPresentation
Presentation
 
Pointers in c
Pointers in cPointers in c
Pointers in c
 
Peer to-peer
Peer to-peerPeer to-peer
Peer to-peer
 
Overview of current communications systems
Overview of current communications systemsOverview of current communications systems
Overview of current communications systems
 
Overall 23 11_2007_hdp
Overall 23 11_2007_hdpOverall 23 11_2007_hdp
Overall 23 11_2007_hdp
 
Objectives of budgeting
Objectives of budgetingObjectives of budgeting
Objectives of budgeting
 
Network management
Network managementNetwork management
Network management
 
Networing basics
Networing basicsNetworing basics
Networing basics
 
Loaders
LoadersLoaders
Loaders
 
Lists
ListsLists
Lists
 
Iris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platformIris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platform
 
Ip sec and ssl
Ip sec and  sslIp sec and  ssl
Ip sec and ssl
 
Ip security in i psec
Ip security in i psecIp security in i psec
Ip security in i psec
 
Intro to comp. hardware
Intro to comp. hardwareIntro to comp. hardware
Intro to comp. hardware
 
Heap sort
Heap sortHeap sort
Heap sort
 

Circle drawing algo.

  • 1. Scan Converting a Circle A circle is a symmetric figure. Any circle generating algorithm can take advantage of the circle’s symmetry to plot eight points for each value that the algorithm calculates. Eight way symmetry is used by reflecting each calculated point around each 45 º axis.
  • 2. y -y,x y,x -x,y x,y x -x,-y x,-y y,-x -y,-x
  • 3. Scan Converting a Circle using Polynomial method:- This method defines a circle with second order polynomial equation y2 = r2 – x2 where x, y = x & y coordinates, r = radius With this method, each x coordinate in the sector, from 90º to 45º, is found by stepping x from 0 to r / 2 , and each y coordinate is found by evaluating r2 – x2 for each step of x.
  • 4. This is a very inefficient method, however, because for each point both x & r must be squared and subtracted from each other; then the square root of the result must be found. y P(x, r2 – x2 ) y r x 0 x
  • 5. Scan Convert a Circle using trigonometric method:- This second method of defining a circle uses functions : x = r cos θ, y = r sin θ y P(r cos θ,r sin θ) r sin θ θ x r cos θ
  • 6. θ = current angle, r = circle radius By this method θ is stepped from θ to π /4 & each value of x & y is calculated. Computation of values of sin θ & cos θ are very time consuming
  • 7. Bresenham’s Circle Algorithm Working: If the eight-way symmetry of a circle is used to generate a circle, points will have to be generated through 45º angle. And, if points are generated from 90º to 45º, moves will be made only in the +x and –y directions. If points are generated from 90º to 45º each new point closest to the true circle can be found by taking either of two actions: (1) Move in the x direction one unit or (2) Move in the x direction 1 unit & -ve y direction 1 unit.
  • 8. y T (xi+1,yi) yi (xi+1,yi-1) yi -1 S r xi xi + 1 x
  • 9. Assume that (xi, yi) are the coordinates of the last scan-converted pixel upon entering step i. Let the distance from the origin to pixel T squared minus the distance to the true circle squared = D(T) = t2 – r2. And let the distance from the origin to pixel S squared minus the distance to the true circle squared = D(S) = s2 – r2. Coordinates of T are (xi +1, yi) S are (xi +1, yi – 1)
  • 10. Following expressions can be developed: D(T) = (xi + 1)2 + yi2 – r2 D(S) = (xi + 1)2 + (yi – 1)2 – r2 This function D provides a relative measurement of the distance from the center of a pixel to the true circle. Since D(T) is always +ve (T is outside the circle) & D(S) will always be –ve (S is inside the true circle), a decision variable di can be defined as:
  • 11. di = D(T) – (-D(S)) = D(T) + D(S) Therefore, di = 2(xi + 1)2 + yi2 + (yi – 1)2 – 2r2 When di<0, we have |D(T)|<|D(S)| and pixel T is chosen. When di>0, we have |D(T)|>|D(S)| and pixel S is selected. Decision variable for next step: di+1 = 2(xi+1 + 1)2 + yi+12 + (y i+1 – 1)2 – 2r2
  • 12. Hence, di+1 – di = 2(xi+1 + 1)2 + yi+12 + (yi+1 – 1)2 - 2(xi + 1)2 - yi2 - (yi – 1)2 Since xi+1 = xi + 1, we have di+1 = di + 4xi + 2(yi+12 - yi2) – 2(yi+1 – yi) + 6 If T is chosen pixel (meaning that di < 0) then yi+1 = yi and so di+1 = di + 4xi + 6 If S is chosen (meaning that di > 0) then y i+1 = yi –1 and so di+1 = di + 4(xi-yi) + 10
  • 13. Hence we have di+1 = di + 4xi + 6 if di < 0 di + 4(xi-yi) + 10 if di > 0 Finally, we set(0,r) to the starting pixel coordinates and compute d1 from the original definition of di: x = 0, y = r d1= 2(0 + 1)2 + r2 + (r-1)2 – 2r2 = 3 – 2r
  • 14. Algorithm: For generating all the pixel coordinates in the 90º to 45º octant that are needed when scan- converting a circle of radius r. (i) int x = 0, y = r, d = 3-2r (ii) while (x <= y) { setpixel(x,y) if (d < 0) d = d + 4x + 6
  • 15. else { d = d + 4(x - y) + 10 y-- } x++ }