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

Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithmAnkit Garg
 
Composite transformations
Composite transformationsComposite transformations
Composite transformationsMohd Arif
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cppAlamgir Hossain
 
Computer graphics chapter 4
Computer graphics chapter 4Computer graphics chapter 4
Computer graphics chapter 4PrathimaBaliga
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clippingMohd Arif
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithmnehrurevathy
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformationAnkit Garg
 
Attributes of Output Primitives
Attributes of Output PrimitivesAttributes of Output Primitives
Attributes of Output PrimitivesRenita Santhmayora
 
Cohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping AlgorithmCohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping AlgorithmMaruf Abdullah (Rion)
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesOmprakash Chauhan
 
Back face detection
Back face detectionBack face detection
Back face detectionPooja Dixit
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformationSelvakumar Gna
 
Anti- aliasing computer graphics
Anti- aliasing computer graphicsAnti- aliasing computer graphics
Anti- aliasing computer graphicsSafayet Hossain
 
4. THREE DIMENSIONAL DISPLAY METHODS
4.	THREE DIMENSIONAL DISPLAY METHODS4.	THREE DIMENSIONAL DISPLAY METHODS
4. THREE DIMENSIONAL DISPLAY METHODSSanthiNivas
 
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPTHOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPTAhtesham Ullah khan
 
3D Transformation in Computer Graphics
3D Transformation in Computer Graphics3D Transformation in Computer Graphics
3D Transformation in Computer Graphicssabbirantor
 

What's hot (20)

Circle generation algorithm
Circle generation algorithmCircle generation algorithm
Circle generation algorithm
 
Composite transformations
Composite transformationsComposite transformations
Composite transformations
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
 
Computer graphics chapter 4
Computer graphics chapter 4Computer graphics chapter 4
Computer graphics chapter 4
 
BRESENHAM’S LINE DRAWING ALGORITHM
BRESENHAM’S  LINE DRAWING ALGORITHMBRESENHAM’S  LINE DRAWING ALGORITHM
BRESENHAM’S LINE DRAWING ALGORITHM
 
Polygon clipping
Polygon clippingPolygon clipping
Polygon clipping
 
Bresenham's line drawing algorithm
Bresenham's line drawing algorithmBresenham's line drawing algorithm
Bresenham's line drawing algorithm
 
fractals
fractalsfractals
fractals
 
Window to viewport transformation
Window to viewport transformationWindow to viewport transformation
Window to viewport transformation
 
Attributes of Output Primitives
Attributes of Output PrimitivesAttributes of Output Primitives
Attributes of Output Primitives
 
Cohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping AlgorithmCohen-Sutherland Line Clipping Algorithm
Cohen-Sutherland Line Clipping Algorithm
 
Clipping
ClippingClipping
Clipping
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 
Back face detection
Back face detectionBack face detection
Back face detection
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformation
 
Anti- aliasing computer graphics
Anti- aliasing computer graphicsAnti- aliasing computer graphics
Anti- aliasing computer graphics
 
4. THREE DIMENSIONAL DISPLAY METHODS
4.	THREE DIMENSIONAL DISPLAY METHODS4.	THREE DIMENSIONAL DISPLAY METHODS
4. THREE DIMENSIONAL DISPLAY METHODS
 
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPTHOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
HOMOGENEOUS CO-ORDINATES IN COMPUTER GRAPHICS PPT
 
3D Transformation in Computer Graphics
3D Transformation in Computer Graphics3D Transformation in Computer Graphics
3D Transformation in Computer Graphics
 

Viewers also liked

Midpoint circle algo
Midpoint circle algoMidpoint circle algo
Midpoint circle algoMohd Arif
 
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
 
Ellipses drawing algo.
Ellipses drawing algo.Ellipses drawing algo.
Ellipses drawing algo.Mohd Arif
 
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
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsDrishti Bhalla
 
Computer graphics
Computer graphicsComputer graphics
Computer graphicsamitsarda3
 
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
 

Viewers also liked (20)

Midpoint circle algo
Midpoint circle algoMidpoint circle algo
Midpoint circle algo
 
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
 
Ellipses drawing algo.
Ellipses drawing algo.Ellipses drawing algo.
Ellipses drawing algo.
 
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.
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
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
 

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
 
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
 
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
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsAmol Gaikwad
 

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
 
Bresenhamcircle derivation
Bresenhamcircle derivationBresenhamcircle derivation
Bresenhamcircle derivation
 
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 Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D
 
Computer Graphics - transformations in 2d
Computer Graphics - transformations in 2dComputer Graphics - transformations in 2d
Computer Graphics - 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
 
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
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithms
 

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++ }