SlideShare a Scribd company logo
1 of 44
Computer Graphics
Lecture 06
Circle Drawing Techniques
Muhammad Munawar Ahmed
What is Circle
A circle is the set of points in a plane that are equidistant from
a given point O. The distance r from the center is called the
radius, and the point O is called the center. Twice the radius
is known as the diameter. The angle a circle subtends from
its center is a full angle, equal to 360° or 2 radians.
Circle Cont..
Circle Cont..
A circle has the maximum possible area for a given
perimeter, and the minimum possible perimeter for a given
area.
The perimeter C of a circle is called the circumference, and is
given by
C = 2  r
Circle Drawing Techniques
- Input for circle drawing
. one center point (xc, yc) and
. radius r
Now, using these two inputs there are a number of ways
to draw a circle.
Circle Drawing Techniques
These techniques have:
- Understanding curve
. very simple to
. complex
- Time complexity
. inefficient to
. efficient
Circle Drawing Using Cartesian
Coordinates
This technique uses the equation for a circle with radius r
centered at (0,0):
x2 + y2 = r2,
an obvious choice is to plot
y = ± r2 - x2
against different values of x.
Circle Drawing Using Cartesian
Coordinates
Using above equation a circle can be easily drawn. The value
of x varies from r-xc to r+xc, and y is calculated using above
formula. Using this technique a simple algorithm will be:
Circle Drawing Using Cartesian
Coordinates
for x= radius-xcenter to radius+xcenter
y = yc + r2 – ( x - xc )2
drawPixel (x, y)
y = yc - r2 – ( x - xc )2
drawPixel (x, y)
Drawbacks/ Shortcomings
This works, but …
. is inefficient
. multiplications & square root
. large gaps in the circle for values of x close to
r
(as shown in the next figure)
Drawbacks/ Shortcomings
Circle Drawing Using Polar Coordinates
Polar Coordinates:
Radius r
Angle 
calculate points along the circular boundary
using polar coordinates r and 
Expressing the circle equation in parametric polar form yields
the pair of equations:
Circle Drawing Using Polar Coordinates
Cont…
x = xc + r cos 
y = yc + r sin 
Using above equation circle can be plotted by calculating x
and y coordinates as  takes values from 0 to 360 degrees or
0 to 2 radians.
Circle Drawing Using Polar Coordinates
Cont…
The step size for  depends on:
. application and
. display device
Larger angular separations along the circumference can be
connected with straight-line segments to approximate the
circular path.
Step size at 1/r gives continuous boundary
This plots pixel positions that are approximately one unit apart.
Polar Coordinates Algorithm
Circle2 (xcenter, ycenter, radius)
for  = 0 to 2 step 1/r
x = xc + r * cos 
y = yc + r * sin 
drawPixel (x, y)
Discussion
- very simple technique
- solves problem of unequal space
- is inefficient in terms of calculations
- involves floating point calculations
Reduction in Calculations
 Symmetry in octants
 Upper half circle symmetric to lower half circle
 Left half circle symmetric to right half circle
 Finally two halves of the same quarters are symmetric to
each other
Eight Octants Symmetry
Optimizing the Algorithm
Now this algorithm can be optimized by using symmetric
octants as:
Circle2 (xcenter, ycenter, radius)
for  = 0 to /4 step 1/r
x = xc + r * cos 
y = yc + r * sin 
DrawSymmetricPoints(xcenter, ycenter, x,y)
Optimized Algorithm
DrawSymmeticPoints (xcenter, ycenter, x, y)
Plot (x + xcenter, y + ycenter)
Plot (y + xcenter, x + ycenter)
Plot (y + xcenter, -x + ycenter)
Plot (x + xcenter, -y + ycenter)
Plot (-x + xcenter, -y + ycenter)
Plot (-y + xcenter, -x + ycenter)
Plot (-y + xcenter, x + ycenter)
Plot (-x + xcenter, y + ycenter)
Inefficiency Still Prevails
 Reduction in calculations by exploiting symmetric octants
but…
 Floating point calculations still involved
Midpoint Circle Algorithm
 Derivation of decision parameter
 Decrement decision in the y coordinate against increment of
x coordinate
Midpoint Circle Algorithm
Consider only the first octant of a circle of radius r centered
on the origin.
We begin by plotting point (0, r) and end when x = y.
Midpoint Circle Algorithm
The decision at each step is whether to choose :
the pixel to the right of the current pixel
or
the pixel which is to the right and below the current pixel
(8-way stepping)
Midpoint Circle Algorithm
Assume:
P = (xk, yk) is the current
pixel.
Q = (xk+1, yk) is the pixel
to the right
R = (xk+1, yk -1) is the
pixel to the right and below.
X = Y
X2- Y2 - r2 =0
Midpoint Circle Algorithm
To apply the midpoint method, we define a circle function:
fcircle(x, y) = x2 + y2 – r2
The following relations can be observed:
f circle (x, y) < 0,if (x, y) is inside the circle boundary
f circle (x, y) = 0,if (x, y) is on the circle boundary
f circle (x, y) > 0,if (x, y) is outside the circle
boundary
Midpoint Circle Algorithm
Circle function tests are performed for the midpoints between
pixels near the circle path at each sampling step.
Midpoint Circle Algorithm
Xk+1
X2+Y2-R2=0
k
k
k
Midpoint Circle Algorithm
Figure given in previous slide shows the midpoint between
the two candidate pixels at sampling position xk+1.
Our decision parameter is the circle function evaluated at the
midpoint between these two pixels:
Decision Parameter
Pk = f circle ( xk + 1, yk - ½ )
Pk = ( xk + 1 ) 2 + ( yk - ½ ) 2 – r 2 ……...(1)
Decision Parameter
If pk < 0, this midpoint is inside the circle and the pixel on
scan line yk is closer to the circle boundary. Otherwise, the
mid position is outside or on the circle boundary, and we
select the pixel on scan-line yk-1.
Decision Parameter
Successive decision parameters are obtained using
incremental calculations. We obtain a recursive expression
for the next decision parameter by evaluating the circle
function at sampling position xk+1+1 = xk+2:
Decision Parameter
Pk+1 = f circle ( xk+1 + 1, yk+1 - ½ )
Pk+1 = [ ( xk + 1 ) + 1 ] 2 + ( yk+1 - ½ ) 2 – r 2
.………(2)
Decision Parameter
Subtracting (1) from (2), we get:
Pk+1 - Pk = [ ( xk + 1 ) + 1 ] 2 + ( yk+1 - ½ ) 2 – r 2 – ( xk + 1 ) 2 - ( yk -
½ ) 2 + r 2
or
Pk+1 = Pk + 2( xk + 1 ) + ( y2
k+1 - y2
k ) – ( yk+1 - yk ) + 1
Decision Parameter
Where yk+1 is either yk or yk-1, depending on the sign of Pk.
Therefore, if Pk < 0 or negative then yk+1 will be yk and the
formula to calculate Pk+1 will be:
Decision Parameter
Pk+1 = Pk + 2( xk + 1 ) + ( y2
k - y2
k )
– ( yk - yk ) + 1
Pk+1 = Pk + 2( xk + 1 ) + 1
Decision Parameter
Otherwise, if Pk > 0 or positive then yk+1 will be yk-1 and the
formula to calculate Pk+1 will be:
Decision Parameter
Pk+1 = Pk + 2( xk + 1 ) + [ (y k -1)2 - y2
k ]
– (yk -1- yk ) + 1
Pk+1 = Pk + 2(xk + 1) + (y2
k - 2 y k +1 - y2
k )
– ( yk -1- yk ) + 1
Pk+1 = Pk + 2( xk + 1 ) - 2 y k + 1 + 1 +1
Pk+1 = Pk + 2( xk + 1 ) - 2 y k + 2 +1
Pk+1 = Pk + 2( xk + 1 ) - 2 ( y k – 1 ) + 1
Decision Parameter
Now a similar case that we observed in line algorithm is that
how would starting Pk be calculated.
For this, the starting pixel position will be (0, r).
Therefore, putting this value in equation, we get
Decision Parameter
P0 = ( 0 + 1 ) 2 + ( r - ½ ) 2 – r 2
P0 = 1 + r2 - r + ¼ – r 2
P0 = 5/4 – r
If radius r is specified as an integer, we can simply round p0
to:
P0 = 1 – r
Since all increments are integer. Finally the algorithm can be
summed up as :
Algorithm
MidpointCircle (xcenter, ycenter, radius)
x = 0;
y = r;
p = 1 - r;
do
DrawSymmetricPoints (xcenter, ycenter, x, y)
x = x + 1
If p < 0 Then
p = p + 2 * ( x + 1 ) + 1
Algorithm Cont…
else
y = y - 1
p = p + 2 * ( x+ 1) –2 ( y – 1 ) + 1
while ( x < y )
Example to calculate first octant of the circle using above
algorithm.
Example
center ( 0, 0 ) radius = 10
Example Cont…
Behaviour of
calculated points
around the circle is
observable

More Related Content

Similar to Computer_Graphics_circle_drawing_techniq.ppt

Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimediasaranyan75
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivessaranyan75
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxNaveenaKarthik3
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer GraphicsKamal Acharya
 
Unit 2
Unit 2Unit 2
Unit 2ypnrao
 
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
 
Shape drawing algs
Shape drawing algsShape drawing algs
Shape drawing algsMusawarNice
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse2013901097
 
Circle drawing algo.
Circle drawing algo.Circle drawing algo.
Circle drawing algo.Mohd Arif
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output PrimitivesPrathimaBaliga
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4Roziq Bahtiar
 
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
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2SanthiNivas
 
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
 

Similar to Computer_Graphics_circle_drawing_techniq.ppt (20)

Output Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and MultimediaOutput Primitives in Computer Graphics and Multimedia
Output Primitives in Computer Graphics and Multimedia
 
Computer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitivesComputer Graphics and Multimedia Output primitives
Computer Graphics and Multimedia Output primitives
 
Unit 3
Unit 3Unit 3
Unit 3
 
Output Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptxOutput Primitive and Brenshamas Line.pptx
Output Primitive and Brenshamas Line.pptx
 
module 1.pdf
module 1.pdfmodule 1.pdf
module 1.pdf
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
Unit 2
Unit 2Unit 2
Unit 2
 
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
 
Shape drawing algs
Shape drawing algsShape drawing algs
Shape drawing algs
 
Computer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipseComputer Graphics - lines, Circles and ellipse
Computer Graphics - lines, Circles and ellipse
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
 
Circle drawing algo.
Circle drawing algo.Circle drawing algo.
Circle drawing algo.
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
 
Open GL T0074 56 sm4
Open GL T0074 56 sm4Open GL T0074 56 sm4
Open GL T0074 56 sm4
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
 
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...
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
 
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
 

More from AliZaib71

Lecture-31.pptx
Lecture-31.pptxLecture-31.pptx
Lecture-31.pptxAliZaib71
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptxAliZaib71
 
CS911-Lecture-21_43709.pptx
CS911-Lecture-21_43709.pptxCS911-Lecture-21_43709.pptx
CS911-Lecture-21_43709.pptxAliZaib71
 
Wireless Networks - CS718 Power Point Slides Lecture 02.ppt
Wireless Networks - CS718 Power Point Slides Lecture 02.pptWireless Networks - CS718 Power Point Slides Lecture 02.ppt
Wireless Networks - CS718 Power Point Slides Lecture 02.pptAliZaib71
 
Web-01-HTTP.pptx
Web-01-HTTP.pptxWeb-01-HTTP.pptx
Web-01-HTTP.pptxAliZaib71
 

More from AliZaib71 (6)

Lecture-31.pptx
Lecture-31.pptxLecture-31.pptx
Lecture-31.pptx
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
SE UML.ppt
SE UML.pptSE UML.ppt
SE UML.ppt
 
CS911-Lecture-21_43709.pptx
CS911-Lecture-21_43709.pptxCS911-Lecture-21_43709.pptx
CS911-Lecture-21_43709.pptx
 
Wireless Networks - CS718 Power Point Slides Lecture 02.ppt
Wireless Networks - CS718 Power Point Slides Lecture 02.pptWireless Networks - CS718 Power Point Slides Lecture 02.ppt
Wireless Networks - CS718 Power Point Slides Lecture 02.ppt
 
Web-01-HTTP.pptx
Web-01-HTTP.pptxWeb-01-HTTP.pptx
Web-01-HTTP.pptx
 

Recently uploaded

ARt app | UX Case Study
ARt app | UX Case StudyARt app | UX Case Study
ARt app | UX Case StudySophia Viganò
 
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Servicejennyeacort
 
Cosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable BricksCosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable Bricksabhishekparmar618
 
定制(RMIT毕业证书)澳洲墨尔本皇家理工大学毕业证成绩单原版一比一
定制(RMIT毕业证书)澳洲墨尔本皇家理工大学毕业证成绩单原版一比一定制(RMIT毕业证书)澳洲墨尔本皇家理工大学毕业证成绩单原版一比一
定制(RMIT毕业证书)澳洲墨尔本皇家理工大学毕业证成绩单原版一比一lvtagr7
 
FiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdfFiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdfShivakumar Viswanathan
 
Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Rndexperts
 
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...katerynaivanenko1
 
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一Fi sss
 
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Passbook project document_april_21__.pdf
Passbook project document_april_21__.pdfPassbook project document_april_21__.pdf
Passbook project document_april_21__.pdfvaibhavkanaujia
 
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一F dds
 
Call Girls Satellite 7397865700 Ridhima Hire Me Full Night
Call Girls Satellite 7397865700 Ridhima Hire Me Full NightCall Girls Satellite 7397865700 Ridhima Hire Me Full Night
Call Girls Satellite 7397865700 Ridhima Hire Me Full Nightssuser7cb4ff
 
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一F La
 
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一diploma 1
 
shot list for my tv series two steps back
shot list for my tv series two steps backshot list for my tv series two steps back
shot list for my tv series two steps back17lcow074
 
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一z xss
 
Design Portfolio - 2024 - William Vickery
Design Portfolio - 2024 - William VickeryDesign Portfolio - 2024 - William Vickery
Design Portfolio - 2024 - William VickeryWilliamVickery6
 
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024CristobalHeraud
 

Recently uploaded (20)

ARt app | UX Case Study
ARt app | UX Case StudyARt app | UX Case Study
ARt app | UX Case Study
 
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
 
Cosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable BricksCosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable Bricks
 
定制(RMIT毕业证书)澳洲墨尔本皇家理工大学毕业证成绩单原版一比一
定制(RMIT毕业证书)澳洲墨尔本皇家理工大学毕业证成绩单原版一比一定制(RMIT毕业证书)澳洲墨尔本皇家理工大学毕业证成绩单原版一比一
定制(RMIT毕业证书)澳洲墨尔本皇家理工大学毕业证成绩单原版一比一
 
FiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdfFiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdf
 
Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025
 
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
 
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
 
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
 
Passbook project document_april_21__.pdf
Passbook project document_april_21__.pdfPassbook project document_april_21__.pdf
Passbook project document_april_21__.pdf
 
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
办理学位证(SFU证书)西蒙菲莎大学毕业证成绩单原版一比一
 
Call Girls Satellite 7397865700 Ridhima Hire Me Full Night
Call Girls Satellite 7397865700 Ridhima Hire Me Full NightCall Girls Satellite 7397865700 Ridhima Hire Me Full Night
Call Girls Satellite 7397865700 Ridhima Hire Me Full Night
 
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
 
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
 
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
 
shot list for my tv series two steps back
shot list for my tv series two steps backshot list for my tv series two steps back
shot list for my tv series two steps back
 
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
 
Design Portfolio - 2024 - William Vickery
Design Portfolio - 2024 - William VickeryDesign Portfolio - 2024 - William Vickery
Design Portfolio - 2024 - William Vickery
 
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
 

Computer_Graphics_circle_drawing_techniq.ppt

  • 1. Computer Graphics Lecture 06 Circle Drawing Techniques Muhammad Munawar Ahmed
  • 2. What is Circle A circle is the set of points in a plane that are equidistant from a given point O. The distance r from the center is called the radius, and the point O is called the center. Twice the radius is known as the diameter. The angle a circle subtends from its center is a full angle, equal to 360° or 2 radians.
  • 4. Circle Cont.. A circle has the maximum possible area for a given perimeter, and the minimum possible perimeter for a given area. The perimeter C of a circle is called the circumference, and is given by C = 2  r
  • 5. Circle Drawing Techniques - Input for circle drawing . one center point (xc, yc) and . radius r Now, using these two inputs there are a number of ways to draw a circle.
  • 6. Circle Drawing Techniques These techniques have: - Understanding curve . very simple to . complex - Time complexity . inefficient to . efficient
  • 7. Circle Drawing Using Cartesian Coordinates This technique uses the equation for a circle with radius r centered at (0,0): x2 + y2 = r2, an obvious choice is to plot y = ± r2 - x2 against different values of x.
  • 8. Circle Drawing Using Cartesian Coordinates Using above equation a circle can be easily drawn. The value of x varies from r-xc to r+xc, and y is calculated using above formula. Using this technique a simple algorithm will be:
  • 9. Circle Drawing Using Cartesian Coordinates for x= radius-xcenter to radius+xcenter y = yc + r2 – ( x - xc )2 drawPixel (x, y) y = yc - r2 – ( x - xc )2 drawPixel (x, y)
  • 10. Drawbacks/ Shortcomings This works, but … . is inefficient . multiplications & square root . large gaps in the circle for values of x close to r (as shown in the next figure)
  • 12. Circle Drawing Using Polar Coordinates Polar Coordinates: Radius r Angle  calculate points along the circular boundary using polar coordinates r and  Expressing the circle equation in parametric polar form yields the pair of equations:
  • 13. Circle Drawing Using Polar Coordinates Cont… x = xc + r cos  y = yc + r sin  Using above equation circle can be plotted by calculating x and y coordinates as  takes values from 0 to 360 degrees or 0 to 2 radians.
  • 14. Circle Drawing Using Polar Coordinates Cont… The step size for  depends on: . application and . display device Larger angular separations along the circumference can be connected with straight-line segments to approximate the circular path. Step size at 1/r gives continuous boundary This plots pixel positions that are approximately one unit apart.
  • 15. Polar Coordinates Algorithm Circle2 (xcenter, ycenter, radius) for  = 0 to 2 step 1/r x = xc + r * cos  y = yc + r * sin  drawPixel (x, y)
  • 16. Discussion - very simple technique - solves problem of unequal space - is inefficient in terms of calculations - involves floating point calculations
  • 17. Reduction in Calculations  Symmetry in octants  Upper half circle symmetric to lower half circle  Left half circle symmetric to right half circle  Finally two halves of the same quarters are symmetric to each other
  • 19. Optimizing the Algorithm Now this algorithm can be optimized by using symmetric octants as: Circle2 (xcenter, ycenter, radius) for  = 0 to /4 step 1/r x = xc + r * cos  y = yc + r * sin  DrawSymmetricPoints(xcenter, ycenter, x,y)
  • 20. Optimized Algorithm DrawSymmeticPoints (xcenter, ycenter, x, y) Plot (x + xcenter, y + ycenter) Plot (y + xcenter, x + ycenter) Plot (y + xcenter, -x + ycenter) Plot (x + xcenter, -y + ycenter) Plot (-x + xcenter, -y + ycenter) Plot (-y + xcenter, -x + ycenter) Plot (-y + xcenter, x + ycenter) Plot (-x + xcenter, y + ycenter)
  • 21. Inefficiency Still Prevails  Reduction in calculations by exploiting symmetric octants but…  Floating point calculations still involved
  • 22. Midpoint Circle Algorithm  Derivation of decision parameter  Decrement decision in the y coordinate against increment of x coordinate
  • 23. Midpoint Circle Algorithm Consider only the first octant of a circle of radius r centered on the origin. We begin by plotting point (0, r) and end when x = y.
  • 24. Midpoint Circle Algorithm The decision at each step is whether to choose : the pixel to the right of the current pixel or the pixel which is to the right and below the current pixel (8-way stepping)
  • 25. Midpoint Circle Algorithm Assume: P = (xk, yk) is the current pixel. Q = (xk+1, yk) is the pixel to the right R = (xk+1, yk -1) is the pixel to the right and below. X = Y X2- Y2 - r2 =0
  • 26. Midpoint Circle Algorithm To apply the midpoint method, we define a circle function: fcircle(x, y) = x2 + y2 – r2 The following relations can be observed: f circle (x, y) < 0,if (x, y) is inside the circle boundary f circle (x, y) = 0,if (x, y) is on the circle boundary f circle (x, y) > 0,if (x, y) is outside the circle boundary
  • 27. Midpoint Circle Algorithm Circle function tests are performed for the midpoints between pixels near the circle path at each sampling step.
  • 29. Midpoint Circle Algorithm Figure given in previous slide shows the midpoint between the two candidate pixels at sampling position xk+1. Our decision parameter is the circle function evaluated at the midpoint between these two pixels:
  • 30. Decision Parameter Pk = f circle ( xk + 1, yk - ½ ) Pk = ( xk + 1 ) 2 + ( yk - ½ ) 2 – r 2 ……...(1)
  • 31. Decision Parameter If pk < 0, this midpoint is inside the circle and the pixel on scan line yk is closer to the circle boundary. Otherwise, the mid position is outside or on the circle boundary, and we select the pixel on scan-line yk-1.
  • 32. Decision Parameter Successive decision parameters are obtained using incremental calculations. We obtain a recursive expression for the next decision parameter by evaluating the circle function at sampling position xk+1+1 = xk+2:
  • 33. Decision Parameter Pk+1 = f circle ( xk+1 + 1, yk+1 - ½ ) Pk+1 = [ ( xk + 1 ) + 1 ] 2 + ( yk+1 - ½ ) 2 – r 2 .………(2)
  • 34. Decision Parameter Subtracting (1) from (2), we get: Pk+1 - Pk = [ ( xk + 1 ) + 1 ] 2 + ( yk+1 - ½ ) 2 – r 2 – ( xk + 1 ) 2 - ( yk - ½ ) 2 + r 2 or Pk+1 = Pk + 2( xk + 1 ) + ( y2 k+1 - y2 k ) – ( yk+1 - yk ) + 1
  • 35. Decision Parameter Where yk+1 is either yk or yk-1, depending on the sign of Pk. Therefore, if Pk < 0 or negative then yk+1 will be yk and the formula to calculate Pk+1 will be:
  • 36. Decision Parameter Pk+1 = Pk + 2( xk + 1 ) + ( y2 k - y2 k ) – ( yk - yk ) + 1 Pk+1 = Pk + 2( xk + 1 ) + 1
  • 37. Decision Parameter Otherwise, if Pk > 0 or positive then yk+1 will be yk-1 and the formula to calculate Pk+1 will be:
  • 38. Decision Parameter Pk+1 = Pk + 2( xk + 1 ) + [ (y k -1)2 - y2 k ] – (yk -1- yk ) + 1 Pk+1 = Pk + 2(xk + 1) + (y2 k - 2 y k +1 - y2 k ) – ( yk -1- yk ) + 1 Pk+1 = Pk + 2( xk + 1 ) - 2 y k + 1 + 1 +1 Pk+1 = Pk + 2( xk + 1 ) - 2 y k + 2 +1 Pk+1 = Pk + 2( xk + 1 ) - 2 ( y k – 1 ) + 1
  • 39. Decision Parameter Now a similar case that we observed in line algorithm is that how would starting Pk be calculated. For this, the starting pixel position will be (0, r). Therefore, putting this value in equation, we get
  • 40. Decision Parameter P0 = ( 0 + 1 ) 2 + ( r - ½ ) 2 – r 2 P0 = 1 + r2 - r + ¼ – r 2 P0 = 5/4 – r If radius r is specified as an integer, we can simply round p0 to: P0 = 1 – r Since all increments are integer. Finally the algorithm can be summed up as :
  • 41. Algorithm MidpointCircle (xcenter, ycenter, radius) x = 0; y = r; p = 1 - r; do DrawSymmetricPoints (xcenter, ycenter, x, y) x = x + 1 If p < 0 Then p = p + 2 * ( x + 1 ) + 1
  • 42. Algorithm Cont… else y = y - 1 p = p + 2 * ( x+ 1) –2 ( y – 1 ) + 1 while ( x < y ) Example to calculate first octant of the circle using above algorithm.
  • 43. Example center ( 0, 0 ) radius = 10
  • 44. Example Cont… Behaviour of calculated points around the circle is observable