1 Introduction

In the realm of computer graphics, representing perfect circles on digital canvases is a challenge that's long been faced by developers and designers. The Midpoint Circle Drawing Algorithm elegantly addresses this challenge, acting as a cornerstone technique for circle generation on raster displays. The algorithm harnesses the inherent symmetry of circles, allowing for efficient and accurate rendering. Instead of calculating every individual pixel value for a circle, it computes for just a segment and then extrapolates for the entire shape, thereby optimizing computational resources. This not only enhances the speed of rendering but also ensures precision, a critical aspect especially when graphics require exactness in representation. Whether it's in sophisticated graphic design software, video game renderings, or basic GUI elements in software applications, the ubiquity of this algorithm underscores its importance in the digital world. Its blend of mathematical simplicity with practical efficiency makes it a fundamental pillar in computer graphics.

In computer graphics, circle drawing stands as a foundational technique. Most graphics software, when generating graphs and visuals, relies heavily on this geometric shape. Over time, various methodologies have emerged for rasterizing circles on screens. Bresenham’s algorithm, introduced by Bresenham [1], remains the most notable circle creation technique, with its variations detailed in works by McIlroy [2] and Liu [3]. An advanced method, introduced by Wu and Rokne [4], offers scan conversion of lines and circles at twice the pixels per iteration, essentially quickening curve generation by increasing increment size. Their findings indicate that their double-step algorithms work as efficiently as single-step ones but with half the iterations. Kuzmin [5] proposed an incremental algorithm that, while producing results identical to Bresenham's, uses fewer arithmetic operations. Liu and Li [6] advocated for a double step circle drawing approach, relying solely on integer arithmetic, and demonstrated its superior speed compared to existing methods. Aken [7] showcased a highly precise midpoint algorithm for drawing ellipses on raster displays, emphasizing its accuracy even when Bresenham’s extended algorithm falls short. In a different vein, Kappel [8] combined previous techniques to formulate an optimized approach for drawing discrete ellipses. Similarly, Fellner et al. [9] have explored efficient algorithms for perfect ellipse approximations. Agathos et al. [10], inspired by Bresenham's methodology, introduced a fast method for rendering conic sections with alignment to coordinate axes. Their method was efficient, used a smaller integer range, and maintained accurate area transitions, even allowing for easy integration of antialiasing. Haiwen et al. [11], using a combined strategy, suggested swift techniques for ellipse drawing. Finally, according to Dimri et al. [12], the midpoint ellipse algorithm remains a preferred method for drawing ellipses, especially with techniques leveraging the reflection around the line x = y using the ellipse's parametric equation. In [13] proposed a method which efficiently detects concentric circles in grayscale images by combining the minimum envelopment circle and the least square ellipse fitting approach. Experimental results indicate superior detection performance compared to classical algorithms. In [14] proposed a circle detection algorithm that corrects elliptical distortions in optical CCD detection by employing ellipse de-falsification and various preprocessing techniques, including the use of RANSAC for outlier removal. The efficacy of this approach is evident in the experimental results, which highlight a minimal detection error of about 0.3%. In [15] presented two optimizations for the Dijkstra algorithm, focusing on urban express traffic: one enhances directional calculation to reduce computational load, and the other optimizes the graphical model by reducing node count. Comparative analysis validates the efficiency of their improved method, streamlining complexity and boosting practical applicability. The study of [16] introduces an approach to detecting multiple ellipses in data, treating the problem through the lens of cluster analysis and envisioning each ellipse as a Mahalanobis circle. By utilizing modified k-means and DIRECT algorithms, the method efficiently identifies ellipses even when their quantity is undetermined, with a novel Geometrical Objects-index (GO-index) assisting in selecting the optimal partition. Notably, while many existing algorithms falter with unclear or noisy ellipse edges, this method excels in such scenarios, as evidenced by numerous test examples.

In this study, we introduce a novel method to minimize errors in the prevailing MPCDA by employing diverse 'h' values to achieve optimal accuracy. The research article is structured into five distinct sections. Section 1 serves as the introduction and sheds light on the latest advancements related to MPCDA. Section 2 delves deeper into the intricacies of the midpoint circle drawing algorithm. In Sect. 3, we illustrate the method by plotting a circle with an 8-unit radius using various 'h' values. The findings are thoroughly discussed in Sect. 4, while Sect. 5 offers a comprehensive conclusion. The final segment of the paper lists the references.

2 Enhancements in Circle Rendering: A Dive into the Improved Algorithm

In our refined algorithm, the x and y coordinates' progression is contingent upon increments or decrements of 'h' units. Our initial focus is on plotting points within the first octant. Leveraging the inherent symmetry of circles, these points then guide the plotting in the subsequent octants. Specifically, for the first octant, plotting begins at the coordinate (0, r), where 'r' denotes the circle's radius.

Taking a circle centered at the origin with a radius of 'r' units, its equation can be defined as x2 + y2 = r2. From this, we derive a function f(x, y) represented as f(x, y) = x2 + y2 − r2. The circle encompasses all points (x, y) that satisfy f(x, y) = 0, assuming x and y as real values. Points satisfying f(x, y) < 0 are found within the circle, whereas those fulfilling f(x, y) > 0 lie outside the circle's boundary. This delineation is visually presented in Fig. 1.

Fig. 1
figure 1

The first and second octant of a circle x2 + y2 = r2

Any point in the first octant may be chosen as (xk, yk), and it is assumed that this point is moving clockwise in the xy-plane. In the first octant, the next point to (xk, yk) is therefore provided by (xk + h, yk) or (xk + h, ykh), where h is the grid's width. So long as (xm, ym) represents the midpoint between (xk + h, yk) and (xk + h, ykh), we have

$$(x_{m} ,\,y_{m} ) = (x_{k} + h,\,y_{k} - h/2).$$

If Pk represents the value of f(x, y) at the mid-point (xm, ym), therefore,

$$P_{k} = f\left( {x_{m} ,y_{m} } \right) = \, \left( {x_{k} + h} \right)^{{2}} + \, \left( {y_{k} {-}h/{2}} \right)^{{2}} {-}r^{{2}} .$$
(1)

Thus, Pk+1 will be given by,

$$P_{{k + {1}}} \,{ = }\,\left( {x_{{k + {1}}} + h} \right)^{{2}} \, + \,\left( {y_{{k + {1}}} {-}h/{2}} \right)^{{2}} {-}r^{{2}}$$
(2)

where, xk+1 = xk + h and yk+1 = yk or ykh. Thus, form Eq. (2), we have

$$P_{{k + {1}}} = \, \left( {x_{k} + { 2}h} \right)^{{2}} + \, \left( {y_{k + 1} {-}h/{2}} \right)^{{2}} {-}r^{{2}} .$$
(3)

On subtracting Eq. (1) from Eq. (3), and then simplifying, we get

$$P_{k + 1} = P_{k} + 2h(x_{k} + h) + (y_{k + 1}^{2} - y_{k}^{2} ) - h(y_{k + 1} - y_{k} ) + h^{2} .$$
(4)

2.1 Initial Decision Parameter

Let the initial point be (0, r), i.e., xk = 0 and yk = r, therefore from Eq. (1), we have

$$P_{k} = h^{2} + (\,r - h/2)^{2} - r^{2} = \frac{5}{4}h^{2} - hr \approx h^{2} - hr.$$

Thus,

$$P_{k} = h\left( {h{-}r} \right).$$
(5)

If Pk ≥ 0, then yk+1 = ykh and the next point will be (xk + h, yk – h), which gives

$$P_{k + 1} = P_{k} + 2h(x_{k} - y_{k} + h) + h^{2} .$$
(6)

If Pk < 0, then yk+1 = yk and the next point will be (xk + h, yk), which gives

$$P_{k + 1} = P_{k} + 2h(x_{k} + h) + h^{2} .$$
(7)

If we take h = 1, then the initial decision parameter from Eq. (5) is Pk = 1 − r and

$$P_{k + 1} = \left\{ \begin{gathered} P_{k} + 2(x_{k} - y_{k} ) + 3,\,P_{k} \ge 0 \hfill \\ P_{k} + 2x_{k} + 3\,\,\,\,\,\,\,\,\,\,\,\,\,\,,\,P_{k} < 0 \hfill \\ \end{gathered} \right.$$

gives the classical case of MPCDA.

3 Results

In this particular analysis, we are implementing the adjusted version of the midpoint circle drawing algorithm to graphically represent a circle, which is defined by a radius spanning 8 units. To simplify this task, we are focusing exclusively on pinpointing and plotting the points located within the first octant, or one-eighth segment of the circle. For this purpose, our starting point is designated as (0, 8).

A noteworthy aspect of this endeavor is the variable 'h'. We have chosen three distinct values for 'h' to examine how they influence the circle's representation. The chosen values are h = 1, h = 0.5, and h = 0.1. Detailed numerical breakdowns for each of these 'h' values are meticulously presented in three separate tables. Specifically, Table 1 is dedicated to the results for h = 1, Table 2 focuses on h = 0.5, and Table 3 encapsulates the data for h = 0.1. To visually illustrate how the circle appears based on these varying 'h' values within the first octant, we have prepared diagrams. Figures 2, 3, and 4 provide graphical representations of the circle corresponding to the 'h' values of 1, 0.5, and 0.1, respectively.

Table 1 Points in the first octant for h = 1
Table 2 Points in the first octant for h = 0.5
Table 3 Points in the first octant for h = 0.1
Fig. 2
figure 2

Original curve versus curve for h = 1 in the first octant

Fig. 3
figure 3

Original curve versus curve for h = 0.5 in the first octant

Fig. 4
figure 4

Original curve versus curve for h = 0.1 in the first octant

Moreover, we have taken it a step further. Beyond just the first octant, we also visualize how the circle is depicted within the entire first quadrant (or one-fourth of the circle) for the aforementioned 'h' values. This broader view can be observed in Figs. 5, 6, and 7, which correspond to the 'h' values of 1, 0.5, and 0.1, respectively.

Fig. 5
figure 5

Original curve versus curve for h = 1 in the first quadrant

Fig. 6
figure 6

Original curve versus curve for h = 0.5 in the first quadrant

Fig. 7
figure 7

Original curve versus curve for h = 0.1 in the first quadrant

In essence, this segment of the study provides both numerical and visual insights into how the modified midpoint circle drawing algorithm functions under different 'h' values, and the results they yield.

4 Discussion

In the research paper at hand, a novel methodology aimed at error minimization for the prevailing Midpoint Circle Drawing Algorithm (MPCDA) is introduced. One of the distinctive features of this approach is the incorporation of variable 'h' values. By fine-tuning these values, it becomes feasible to considerably lower the associated errors, pushing the limits of accuracy in circle rendering.

Proceeding to Sect. 2, a deep dive into the intricacies of the midpoint circle drawing algorithm is undertaken. Here, readers are offered a detailed understanding of the algorithm's core mechanics, functioning, and its foundational principles.

Section 3 transitions into a practical application of the discussed algorithm. In this segment, a circle, characterized by a radius measuring 8 units, is plotted. The unique aspect here is the deployment of diverse 'h' values during the plotting process, showcasing the algorithm's adaptability and the influence of varying 'h' values on the outcome.

Subsequently, Sect. 4 delves into a thorough discussion of the results obtained from the previously demonstrated example. This section aims to shed light on the implications, significance, and potential applications of the findings, making it crucial for those seeking actionable insights or future research directions.

5 Conclusion

In conclusion, the rendering of circles on digital platforms holds undeniable importance in the realm of computer graphics, and the widely embraced midpoint circle algorithm stands out as a premier tool for this fundamental task. Throughout this article, we have delved into the foundational aspects of the algorithm, shedding light on its remarkable capabilities in facilitating accurate and seamless circle depiction on digital displays. The significance of the midpoint circle algorithm becomes even more apparent as we contrast its merits with alternative circle drawing techniques. Its efficiency and effectiveness in achieving precision set it apart as a reliable choice for graphic rendering. However, acknowledging the inherent inaccuracies in the standard cartesian-based Midpoint Circle Drawing Algorithm (MPCDA), our research has introduced a refined technique. The core focus of our enhancement lies in the integration of an error-reduction strategy, aimed at minimizing inaccuracies that may arise during the rendering process. This nuanced approach ensures greater accuracy in depicting circles, addressing a key concern associated with the traditional MPCDA. The comparative tests conducted on diverse circle sizes and placements substantiate the efficacy of our enhanced method. When pitted against results obtained using the traditional MPCDA, our approach not only demonstrates its prowess but also showcases significant improvements. The refined technique not only preserves the strengths of the original algorithm but elevates its performance, making it a compelling choice for digital circle rendering in computer graphics.

In essence, the research presented here contributes to the ongoing evolution of circle rendering techniques, providing a valuable refinement to a widely adopted algorithm. As digital displays continue to play an increasingly integral role in various fields, the pursuit of accuracy and efficiency in graphical representation becomes paramount, and our enhanced midpoint circle algorithm contributes significantly to this endeavor.