0% found this document useful (0 votes)
39 views

Midpoint Distance Circle Generation Algorithm Base

This paper proposes a new midpoint distance circle generation algorithm that combines the midpoint circle algorithm and Bresenham circle algorithm. It first calculates the positional relationship between the midpoint and circumference of two adjacent pixel points. It then calculates the distance difference between these points and the circle using two approximate distances. This allows it to obtain decision parameters for the algorithm. By using the symmetry of the octant, it can generate a complete circle. Experiments show this algorithm has higher stability and precision than similar algorithms, with less resource consumption and more flexible calculation methods.

Uploaded by

Yahya Alqadhi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Midpoint Distance Circle Generation Algorithm Base

This paper proposes a new midpoint distance circle generation algorithm that combines the midpoint circle algorithm and Bresenham circle algorithm. It first calculates the positional relationship between the midpoint and circumference of two adjacent pixel points. It then calculates the distance difference between these points and the circle using two approximate distances. This allows it to obtain decision parameters for the algorithm. By using the symmetry of the octant, it can generate a complete circle. Experiments show this algorithm has higher stability and precision than similar algorithms, with less resource consumption and more flexible calculation methods.

Uploaded by

Yahya Alqadhi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Journal of Physics: Conference Series

PAPER • OPEN ACCESS

Midpoint Distance Circle Generation Algorithm based on Midpoint Circle


Algorithm and Bresenham Circle Algorithm
To cite this article: Minghua Cao et al 2020 J. Phys.: Conf. Ser. 1438 012017

View the article online for updates and enhancements.

This content was downloaded from IP address 178.171.58.183 on 11/01/2020 at 01:27


CCISP 2019 IOP Publishing
Journal of Physics: Conference Series 1438 (2020) 012017 doi:10.1088/1742-6596/1438/1/012017

Midpoint Distance Circle Generation Algorithm based on


Midpoint Circle Algorithm and Bresenham Circle Algorithm

Minghua Cao1,a, Siyuan Liu2,b and Fanghua Cao3*,c


1
Department of Computer Science and Technology, University of Electronic Science
and Technology of China, Faculty of Computer Science and Engineering, No. 2006
Xiyuan Avenue, Chengdu, China.
2
University of Electronic Science and Technology of China, Faculty of Public
Administration, Chengdu, China.
Email:
3*
Hubei Yikatong Technology Co., Ltd. Shanghai City, China.

Email: [email protected]; [email protected];


c
[email protected]

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

2.1. Definition of circle


Define the center of the circle ( xc , yc ) , Radius is r, the coordinates of any point on the circle are
( x, y) . Since the circle at any point can be obtained by the translation transformation of the
coordinates [3], in order to simplify the complexity of the algorithm, Let the coordinates of the center
of the circle be (0, 0), then there is a point coordinate equation for the circle.

x2  y2  r2 (1)

2.2. Octagon circle


For any kind of circle generation algorithm, the symmetry of the circle can be used to reduce the
amount of calculation. The circle with the center of the origin has four axes of symmetry, which are
x  0, y  0, y  x, y   x , if any point P(x, y) on the circumference is known, then the other seven
symmetry points on the circumference can be obtained by four symmetry axes, which are (y, x), (-x,
y), (x, -y), (y, -x), (-y, x), (-x, -y), (-y, -x), This property is called the octant symmetry of the circle [3,
8, 9]. Therefore, with the octave symmetry of the circle, in the case of knowing the four symmetry
axes of the circle, the entire circle can be drawn by drawing an arbitrary arc of one eighth.

Figure 1. Midpoint circle algorithm. Figure 2. Bresenham circle algorithm.

3. Midpoint circle algorithm


In the computer graphics circle generation algorithm, because of the need to display or output graphics
on the dot matrix output device, a raster scan conversion algorithm [3,6] is also needed to perform
pixel point conversion. Directly using the point coordinate equation to calculate the position of the
point on the circle requires multiplication and square root operations, which will increase the
computational cost and algorithm complexity. Therefore, the method of drawing the midpoint circle is
introduced.
Set the circular function to

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

When dmk  0 , yk 1  yk , then dmk  2 xk  3  2( xk  1)  1  2 xk 1  1 ; when dmk  0 ,


yk 1  yk -1  yk  1 , then dmk  (2 xk  3)  2( yk  1)  2 xk 1  2 yk 1  1 .
which is

 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).

4. Bresenham drawing circle algorithm


The principle of Bresenham's circle algorithm [5,10] is similar to that of the midpoint circle algorithm.
The difference is that the Bresenham circle algorithm simplifies the calculation and makes full use of
the principle of similarity to simplify the problem.
The Bresenham circle algorithm uses the line segment EH shown in Figure 2 instead of the line
segment HN. The line segment LG is used instead of the line segment NL. The magnitude relationship
between HN and NL is reflected by the positive and negative of EH-LG. For the center of the circle,
the radius is r. The drawing process of one arc, the derivation process of the decision parameters of the
Bresenham circle algorithm is as follows:

3
CCISP 2019 IOP Publishing
Journal of Physics: Conference Series 1438 (2020) 012017 doi:10.1088/1742-6596/1438/1/012017

dbk  dbHN  dbNL  dbEH  dbLG  (dbOH  dbOE )  (dbOG  dbOL )


(8)
 ( x k2 1  y k2  r )  (r  x k2 1  y k2 1 )
Since the above operation is still designed to be squared, the above equation is approximated as

dbk  (x k  1)2  y k2  r 2   r 2  (x k  1)2  (y k  1)2 


(9)
 2(x k  1)2  2y k2  2y k  1  2r 2
The increment of the decision parameter is
dbk  dbk 1  dbk
 2(x k 1  1)2  2y k2 1  2y k 1  1  2r 2   2(x k  1)2  2y k2  2y k  1  2r 2  (10)
 4x k  6  2(y k2 1  y k2  y k 1  y k )

When dbk  0 , yk 1  yk , then dbk  4 xk  6 ; when dbk  0 , yk 1  yk -1  yk  1 , then


dbk  4( xk  yk )  10 .
Which is
 dbk  4x k 1  6,dbk  0
dbk 1  dbk  dbk   (11)
dbk  4(x k  y k )  10,dbk  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.
db0  3  2r (12)
The coordinates of the next point can be obtained from equation (4), (11) and (12).

Figure 3. Midpoint distance circle generation Figure 4. Comparison of three algorithms.


algorithm.

5. Midpoint distance circle generation algorithm


As shown in Figure 3, the midpoint distance circle generation algorithm combines the advantages of
the midpoint circle algorithm and the Bresenham circle algorithm, using both the midpoint as the

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.

You might also like