3
COI~PUTNtt GRAPHICS AND Ii~L~.GE PROCESSING 6, 196--198 (1977) NOTE On Circle Generation Algorithms Wo~r L. C~u~G Deparbnen~ of Statistics and Computer Science, University of Delaware, Newark, Delaware 19711 Received February 18, 1976 Criteria for comparing circle generation algorithms are presented, and au algorithm opeimal with regard to these criteria is described. In his note [2], Kameswara Rao compared two algorithms for circle generation by Denert [-3] and by Lappalainen and Ojala [-4]. His conclusion that the latter is superior to the former seems to be too subjective, lacking the objective use of criteria for the comparison which should be based on the functional and computa- tional merits of the algorithm. Two ~lgorithms are comparable in the sense that they use straight line segments as primitive components and require only integer arithmetic. In the following discussion, specific criteria will be presented for comparing the various circle generation Mgorithms [1, 3, 4-7] and an algorithm will be dis- cussed as optimal with regard to these criteria. The following criteria for goodness or optimality of a circle generation algorithm are proposed in consideration of the geometric properties of a circle and functional requirements for display. Criterion 1. Symmetry and uniformity of the approximation; both esthetic and functional considerations. Criterion 2. Closeness of the approximation: (i) min ]r -- d~'l, where r = radius and d~j = distance from the center to the grid point (xl, y~). (ii) min [f(x~, yj) ] = min [x~ ~ + yj2 _ r-"[. (iii) rain [area of circle -"area of approximation[. Criterion 3. Computational complexity; speed and economy. The best algorithm in the sense of the above criteria was originally suggested by Jordan, Lennon, and Holm [5]. The circle generation algorithm in [5] was given as a special case of a more general algorithm that can handle a limited class of conics. A simplified version will be given in the following. We assume without Joss of generality that the direction of generation is clockwise. The nonparametric 196 Copyright @ 1977 by Academic Press, Ine, All righta of reproduction in uny form reserved.

On circle generation algorithms

Embed Size (px)

Citation preview

Page 1: On circle generation algorithms

COI~PUTNtt GRAPHICS AND Ii~L~.GE PROCESSING 6, 196--198 (1977)

NOTE

On Circle Generation Algorithms

Wo~r L. C~u~G

Deparbnen~ of Statistics and Computer Science, University of Delaware, Newark, Delaware 19711

Received February 18, 1976

Criteria for comparing circle generation algorithms are presented, and au algorithm opeimal with regard to these criteria is described.

In his note [2], Kameswara Rao compared two algorithms for circle generation by Denert [-3] and by Lappalainen and Ojala [-4]. His conclusion that the latter is superior to the former seems to be too subjective, lacking the objective use of criteria for the comparison which should be based on the functional and computa- tional merits of the algorithm. Two ~lgorithms are comparable in the sense that t hey use straight line segments as primitive components and require only integer arithmetic.

In the following discussion, specific criteria will be presented for comparing the various circle generation Mgorithms [1, 3, 4-7] and an algorithm will be dis- cussed as optimal with regard to these criteria. The following criteria for goodness or optimality of a circle generation algorithm are proposed in consideration of the geometric properties of a circle and functional requirements for display.

Criterion 1. Symmetry and uniformity of the approximation; both esthetic and functional considerations.

Criterion 2. Closeness of the approximation:

(i) min ]r -- d~'l, where r = radius and d~j = distance from the center to the grid point (xl, y~).

(ii) min [f(x~, yj) ] = min [x~ ~ + yj2 _ r-"[. (iii) rain [area of circle -"area of approximation[.

Criterion 3. Computational complexity; speed and economy.

The best algorithm in the sense of the above criteria was originally suggested by Jordan, Lennon, and Holm [5]. The circle generation algorithm in [5 ] was given as a special case of a more general algorithm that can handle a limited class of conics. A simplified version will be given in the following. We assume without Joss of generality that the direction of generation is clockwise. The nonparametric

196

Copyright @ 1977 by Academic Press, Ine, All righta of reproduction in uny form reserved.

Page 2: On circle generation algorithms

i .

: : ] :

i

I I I ' ~ [ i i [ 1

i i i i i

i

J ~ L

122 g

- i

II

I!

- - i

i

~ - i ¸

~ + , L

i '

, i

i I

I

197

. . . . L . . . . ~ w - -

t ~ . F - I i

i 1

I ] i ~ I

I . . . .

i i l

I I I

I

J

i

!

- ! I

I i

i

In

I

i '

I

I

i

- I i

I

o

, . Q

r-~

J o

v

Page 3: On circle generation algorithms

198 . WON L. CHUNG

form of a circle, f (x , y) = x ~ + y2 _ : = 0, is used. The use of a rect,'mgular grkI of uni t lengt, h implies tha t hx and Ay are 1, - 1 , or 0.

SI. Select three candidates for the next grid point. Due to the speci,'~] proper ty of a circle: f(x, y) < 0 at all points inside the circle and .f(x, y) > 0 at all points outside the circle, they are simply determined by

Sign(hx) = Sign(y); Sign(Ay) = S i g n ( - x ) . (1)

$2. Determine the next point by comparing the v',~htes of I f (x{, y]) 1 "~t~ the candidate points. Let f~,~ be the value of f (x , y) at the present point. Then,

,f~.~+l ~- .f(:% y~ "~- hy) = f.~,~ + 2y (hy) + 1, (2)

Le t a, b, and c be logical wu'iables determined by t,he signs of

1.I'i+I,~[- [f~,~.l-ll, l,f~+1,~l- [f~+1,,.-:[, and l,f;,,'-:l - [,f~+t,;,-ll.

Then the final point is determined by

IA=I = a . S v b . c (3)

[ ~ y [ = a .evb .c

This ~lgorithm turns cut to be equivalent to the residue alger[{~hm of Freeman [7] . But the algorithm in [7] is less attractive because the c'omputtti, ion el' the residue becomes time consuming for circles of large radius, q?he above algori thm requires only simple Boolean ]!unctions for (1) and (3), and addi t ion (or subln:ae- tion) and shift for (2) using integer arithmetic. The algorit, hm has no degeneration problem at all. It can be readily implemmlted by a simple combinator ial circuit, as well as in software. Therefore, it is comparable to or even bet ter t han the DDA method in [1]. I t is clearly seen that this method is better t han other methods [3, 4, 6] with regard to our optimality criteria. The same example as in [2], with radius r = 23, is used for illustration in Fig. 1.

REFERENCES

]. P. G. McCrea and P. W. Baker, On DDA circle generation for computer graphics, ]EEE TC, C-24, ]975, 1109-1110.

2. C. V. Kameswara Rao, Comment on a ine~hod for computing points of a circle using truly integers, Computer Graphics and Image Processing, 1974, 79.

3. E. Denert, A Method for computing points o1' a circle using only inl:egers, Compuler Graphics and Image Processing 1973, 83-91.

.4. P. Lappalainen and L. Ojala, A Novel met,hod of generating a circle test pat~tern for Televisiol b Radio Eng. Electron., 1972~ 21.

5. B. W. Jordan, W. J. Lennon, a~d B. D. Holm, An improved algorit~hm for t~lle genm'ation of nonparametric curves, IEEE TC, C-22, 1973, 1052-1060.

8. P. E. Danielsson, Incremental curve generat.ion~ IEEE TC, C-19, 1970, 783-793. 7. H. Freem~n, A review of relevant problems in the processing of line-drawing dat~a, in AulomaEe

Inlerpretalion and Classification of Images (A. Grasselli, Ed.), pp. 155-174, Academic, Prcss~ New York, 1969.