Midpoint Distance Circle Generation Algorithm Base
Midpoint Distance Circle Generation Algorithm Base
Abstract. In the process of generating a circle, the existing midpoint circle algorithm and
Bresenham circle algorithm have the problems of slow drawing speed, high resource
consumption, complicated calculation steps and large pixel spacing in some areas, and a
combination of midpoint painting is proposed. A new algorithm for the circular algorithm and
the Bresenham circular algorithm. The algorithm first calculates the positional relationship
between the midpoint and the circumference of two adjacent pixel points, and then calculates
the distance difference between two adjacent pixel points and the circle by two approximate
distances, and then obtains the decision parameters of the algorithm. A complete circle is
obtained by the symmetry of the octant. Experiments show that the proposed algorithm is an
effective midpoint distance circle generation algorithm based on the midpoint circle algorithm
and the Bresenham algorithm. Compared with similar algorithms, it has higher stability and
precision, and has less resource consumption and more flexible calculation methods.
1. Introduction
Graphics are usually composed of basic elements such as points, lines, faces, and bodies. Lines are
divided into lines and curves. The algorithm for generating curves can be divided into line generation
algorithm [1] and point generation algorithm [2]. Circle is a commonly used perfect figure. The circle
generation algorithm is a basic algorithm in computer graphics [3]. Common circle generation
algorithms mainly include midpoint circle algorithm [4], Bresenham circle algorithm [5] and positive
and negative The circle algorithm [6] is classified into three categories, but all three algorithms have
their own problems [6,7]. In order to solve the above problems, this paper proposes a new algorithm
combining the advantages of the midpoint circle algorithm and the Bresenham circle algorithm.
2. Basic Principles
Introduce the basic principles that all algorithms need to use and the theory to be used in algorithm
optimization.
Content from this work may be used under the terms of the Creative Commons Attribution 3.0 licence. Any further distribution
of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI.
Published under licence by IOP Publishing Ltd 1
CCISP 2019 IOP Publishing
Journal of Physics: Conference Series 1438 (2020) 012017 doi:10.1088/1742-6596/1438/1/012017
x2 y2 r2 (1)
f(x ,y ) x 2 y 2 r 2 (2)
Using the octave symmetry of the circle, only the arc between point A and point B in the Figure 1
is studied, and the coordinates of any point between the drawn arcs AB are Pk ( xk , yk ) , so on and so
1
forth, Pk 1 ( xk 1 , yk 1 ) , M k 1 ( xk 1 , yk ) is the midpoint of ( xk 1 , yk ) and ( xk 1 , yk 1 ) , among
2
them, xk 1 xk 1, yk 1 yk 1, yk 1 yk 1.
Set the decision parameters to
2
CCISP 2019 IOP Publishing
Journal of Physics: Conference Series 1438 (2020) 012017 doi:10.1088/1742-6596/1438/1/012017
1 1
dm k f(x k 1 ,y k ) (x k 1)2 (y k )2 r 2 (3)
2 2
1
When dmk 0 , the midpoint M k 1 ( xk 1 , yk ) is in the circle, the point on the arc specified at
2
1
this time is closer to point ( xk 1 , yk ) ; when dm k 0 , the midpoint M k 1 ( xk 1 , yk ) is on the
2
circle or outside the circle, the point on the arc specified at this time is closer to point ( xk 1 , yk 1 ) .
Therefore,
(x k 1 ,y k ),dm k 0
Pk 1 (4)
(x k 1 ,y k 1 ),dm k 0
That is, the value of yk 1 is determined by the positive or negative of the decision parameter dmk .
Set the increment of the decision parameter to
1 1
dm k dm k 1 dm k f (x k 1 1,y k 1 ) f(x k 1 ,y k )
2 2
1 1
(x k 2)2 (y k 1 )2 (x k 1)2 (y k )2 (5)
2 2
(2x k 3) (y k 1 y k ) (y k y k 1 )
2 2
dm k 2x k 1 1,dm k 0
dm k 1 dm k dm k (6)
dm k 2x k 1 2y k 1 1,dm k 0
Substituting the circular function at the starting position coordinate ( xk , yk ) (0, r ) into the above
circular function to obtain the initial value of the decision parameter.
5
dm 0 r (7)
4
The coordinates of the next point can be obtained from equation (4), (6) and (7).
3
CCISP 2019 IOP Publishing
Journal of Physics: Conference Series 1438 (2020) 012017 doi:10.1088/1742-6596/1438/1/012017
4
CCISP 2019 IOP Publishing
Journal of Physics: Conference Series 1438 (2020) 012017 doi:10.1088/1742-6596/1438/1/012017
judgment basis and the distance approximation as the decision factor. Let the decision parameter of the
midpoint distance circle algorithm be
d k dm k dbk (13)
among them, dmk is the decision parameter of the midpoint circle algorithm, which can be obtained
by equations (6) and (7), dbk is the decision parameter of the Bresenham circle algorithm, which can
be obtained by equations (11) and (12), α and β are the coefficients of the above two decision
parameters, respectively, satisfying 1,0 1,0 1 .
The recursive expression of the decision parameter of the available midpoint distance circle
generation algorithm is
(dm k 2x k 1 1) (dbk 4x k 1 6),dm k 0 and dbk 0
(dm k 2x k 1 2y k 1 1) (dbk 4(x k y k ) 10),dm k 0 and dbk 0
d k 1 (14)
(dm k 2x k 1 1) (dbk 4(x k y k ) 10),dm k 0 and dbk 0
(dm 2x k 1 2y k 1 1) (dbk 4x k 1 6),dm k 0 and dbk 0
k
Substituting the circular function at the starting position coordinate ( xk , yk ) (0, r ) into the above
circular function to obtain the initial value of the decision parameter.
5
d 0 ( r ) (3 2r ) (15)
4
It is verified by experiments that when α is 0.62 and β is 0.38, the actual experimental results of
decision parameters are relatively good, so equation (15) can be rewritten as
5
d 0 0.62 ( r ) 0.38 (3 2r ) 1.915 1.38r (16)
4
Equation (16) still involves floating-point operations, so simple rounding of floating-point numbers
is obtained.
5
d 0 0.62 ( r ) 0.38 (3 2r ) 2 r (17)
4
Although the decision to select pixel points using equation (17) is more accurate, the parameters α
and β can still be adjusted in real life to achieve the best experimental results.
Therefore, the steps of the midpoint distance circle generation algorithm are as follows:
1. Use the radius r and the center coordinates ( xc , yc ) of the circle and the first point (0, r) on the
circumference as the known quantity
2. Calculate the initial value of the decision parameter d 0 2 r
3. Starting from the coordinates of the starting position, the x-axis coordinate is incremented by one
pixel at a time. The value of the corresponding decision parameter is calculated according to the value
of the previous decision parameter by (14), and the next pixel is judged according to the formula (4).
coordinate
4. Calculate the coordinates of the corresponding symmetrical points of the remaining 7 octants
5. Move the calculated pixel point ( xk , yk ) through the translational transformation of the
coordinates to the circumference of the center: xk xc xk , yk yc yk
6. Repeat steps 3-5 until y x , that is, complete the drawing of the circle.
5
CCISP 2019 IOP Publishing
Journal of Physics: Conference Series 1438 (2020) 012017 doi:10.1088/1742-6596/1438/1/012017
6. Simulation
Opengl programming is used to realize the midpoint circle algorithm, Bresenham circle algorithm and
the midpoint distance algorithm of this paper, and the experiment was run 16 times. The experimental
results show that the proposed algorithm is a circle generation algorithm with high efficiency, strong
stability and high flexibility. The result is shown in Figure 4.
7. Conclusions
The midpoint distance circle generation algorithm based on the midpoint circle algorithm and the
Bresenham algorithm proposed in this paper is an easy to implement and simple calculation algorithm.
Compared with the midpoint circle algorithm, the calculation process of floating point numbers is
omitted. Compared with the Bresenham algorithm, it is more flexible and controllable. Therefore, the
proposed algorithm is a feasible circle generation algorithm.
8. Conflicts of interest
The authors declare that there is no conflict of interest regarding the publication of this paper.
9. Data availability
Data used to support the findings of this study are included with in the article.
References
[1] JIA Yin-liang, ZHANG Huane-hun, JING Ya-zhiA. Modified Bresenham Algorithm of
Line Drawing[J]. JOURNAL OF IMAGE AND GRAPHICS, 2008, 13(1):163-166.
[2] LAI Yuan, FENG Huanqing, ZHUGE Bin. An Algorithm of Mesh Point Generation for
Surface Reconstruction[J]. COMPUTER ENGINEERING AND APPLICATIONS,
2002, 38(3):83-84.
[3] Jiaguang Sun.Computer Graphics[M].Beijing:Tsinghua university press,1998.
[4] ZHU Xiao-lin, GAO Cheng-hui, HE Bing-wei, HUANG Min-chun, CHEN Jie. An
Improved Method of Hough Transform Circle Detection Based on the Midpoint Circle-
Producing Algorithm[J]. JOURNAL OF ENGINEERING GRAPHICS, 2010, 31(6):29-
33.
[5] Wang Zhixi, Wang Runyun. Improvement of Bresenham's Circle Generation
Algorithm[J]. COMPUTER ENGINEERING, 2004, 30(12):178-180.
[6] Shi Zhixin. Research on Basic Raster Graphics Generation Algorithm[D]. ShanDong
University, 2007.
[7] Lin Yun, Tan Wei-xian, Hong Wen, Wang Yan-ping, Wu Yi-rong. Polar Format
Algorithm for Circular Synthetic Aperture Radar[J]. JOURNAL OF ELECTRONICS &
INFORMATION TECHNOLOGY, 2007(9):58-58.
[8] Wang Xide, Fang Qingyan. General conic curve algorithm based on octant arc[J].
HELONGJIANG SCIENCE AND TECHNOLOGY INFORMATION, 2007(9):58-58.
[9] Wang Runyun, Wang Zhixi. A Kind of Fast and Accurate Algorithm for Circle
Generation[J]. JOURNAL OF SICHUAN UNIVERSITY OF SCIENCE AND
TECHNOLOGY, 2004, 23(3):43-44.
[10] Donald Hearn,M Baker.Computer Graphics with OpenGL [M]. Prentice Hall,2003.