Efficient Integer Algorithms For The Generation of Conic Sections
Efficient Integer Algorithms For The Generation of Conic Sections
621±628, 1998
# 1998 Elsevier Science Ltd. All rights reserved
PII: S0097-8493(98)00069-7 Printed in Great Britain
0097-8493/98/$ - see front matter
Technical Section
AbstractÐEcient integer 8-connected algorithms for the fast generation of Conic Sections whose axes
are aligned to the coordinate axes are described based on a Bresenham-like methodology. Performance
results show that in the case of the ellipse, the algorithm is at least as fast as other known integer algor-
ithms but requires lower integer range and always performs correct region transitions. Antialiasing is
easily incorporated. # 1998 Elsevier Science Ltd. All rights reserved
621
622 A. Agathos et al.
The above expression is monotonically increasing in each step in the generation the X value is therefore
the interval e $ (ÿ1,yi]. We can therefore use the always incremented. It must be determined whether
value of d(e) at e = 1/2 i.e. d(1/2) = 1/2 as the de- the Y value should be decremented or not. This
cision value: region corresponds to the 2nd octant of the circle
(Fig. 1) and we de®ne:
if d R 1/2 then pixel B is chosen
else pixel D is chosen. d1 y2i ÿ y2
d2 y2 ÿ yi ÿ 12 ,
Note that since d is the integer, we can replace as in the case of the circle. Taking as decision vari-
the 1/2 by 0, without aecting the semantics. Note able:
that what we really accomplish here is to simulate a d a2
d1 ÿ d2,
midpoint-type technique [1].
Due to the 8-way symmetry of the circle, we need the following will hold (Fig. 1):
not consider another octant; in the case of the
if dRa2 =2 then pixel B
x i 1, yi is chosen
ellipse, which has 4-way symmetry, we need to con-
sider 2 regions which make up one-quarter of the else pixel D
x i 1, yi ÿ 1 is chosen:
2
ellipse.
The only reason for multiplying by a2 is to facilitate
its incremental derivation (see below). Of course the
3. DERIVATION OF THE ELLIPSE GENERATING division of the integer value a2 by 2 can be replaced
ALGORITHM by one Right Shift of a2; since d is an integer the
Consider an ellipse centered at the origin of the result is semantically equivalent.
2D cartesian space de®ned by: We next derive the incremental computation of
the decision variable; its value for the ith step of
x 2 =a2 y2 =b2 1
the algorithm in Region 1 is:
The ellipse has a 4-way symmetry and it is therefore d1,i a2
d1 ÿ d2
only necessary to generate its arc in the ®rst quad-
rant. Here we distinguish two regions separated by a2 y2i a2
yi ÿ 12 ÿ 2a2 y2
the point on the ellipse where dy/dx = ÿ 1. In the
®rst region the axis of major movement is X and in
the second Y (Fig. 2).
We must derive an incremental expression for the
decision variables in Regions 1 and 2, the initial
values of the decision variables and a condition to
detect the transition from Region 1 to Region 2.
Fig. 4. Ellipse Construction (Region 2) Fig. 5. Midpoint and Antialiased ellipse (4 Bits per pixel)
Ecient integer algorithms 625
b2 b2
x i 12 ÿ b2 x 2
4. THE HYPERBOLA AND PARABOLA ALGORITHMS
Setting e = x ÿ xi we get:
In a similar manner to the ellipse, one can derive
incremental error expressions for the construction d
e d1 ÿ d2
of our hyperbola and parabola generating algor-
ithms. 2b2 e2 4b2 x i e ÿ b2 ÿ 2b2 x i :
5
which can be incrementally derived to be: In a manner similar to the ellipse, the transition cri-
2
terion from Region 1 to Region 2 is as follows:
if d1,i rÿ b /2 then xi+1=xi + 1 by
Equation (6), thus if d < 4 b2(xi+1) ÿ b2/2 then we remain in the
d1,i1 d1,i 2a2 4a2
yi 1 ÿ 4b2
x i 1, same region else we
if d1,i<ÿ b2/2 then xi+1=xi by Equation (6), change region.
thus
REFERENCES
if d1,i<0 then xi+1=xi, thus
1. Pitteway, M. L. V., Algorithms for drawing ellipses
or hyperbolae with a digital plotter. Computer J.,
d1,i1 d1,i 2
yi 1 1, 1967, 10(3), 282±289.
2. Bresenham, J. E., A linear algorithm for incremental
digital display of circular arcs. CACM, 1977, 20(2),
100±106.
In Region 2, expressions for a measure of the dis- 3. Van Aken, J. R., An ecient ellipse-drawing algor-
tance of the true parabola to the 2 nearest pixel ithm. CG&A, 1984, 4(9), 24±35.
centers are: 4. Kappel M. R., An Ellipse-Drawing Algorithm for
Raster Displays. In Earnshaw R. (ed) Fundamental
d1
yi 12 ÿ y2 Algorithms for Computer Graphics, NATO ASI Series,
Springer-Verlag, Berlin, 1985, pp. 257±280.
d2 y2 ÿ y2i 5. Pitteway M. L. V. and Ebadollah Banissi, Soft
Edging Fonts. Computer Graphics Technology and
Systems. In Proceedings of the conference held at
The error term is:
Computer Graphics `87, London, October 1987.
d2,i d1 ÿ d2 6. McIlroy, M. D., Getting Raster ellipses right. ACM
TOG, 1992, 11(3), 259±275.
7. Da Silva D., Raster Algorithms for 2D Primitives.
yi 12 y2i 4p
x i 1 Master's Thesis, Computer Science Department,
Brown University, Providence, R.I., 1989.
which can be incrementally derived to be: 8. Fellner W. D., Computer Gra®k. Bibliogra®sches
if d2,i<0 then yi+1=yi+1, thus Institut, Zuerich, 1992.
9. Foley J. D. et al., Computer Graphics, Principles and
Practice, 2nd Edn. Addison-Wesley, 1990.
d2,i1 d2,i 4
yi 1 ÿ 4p, 10. Wu, X., An ecient antialiasing technique. Computer
Graphics, 1991, 25(4), 143±152.
5. CONCLUSIONS
APPENDIX C
Parabola Pascal Code
APPENDIX B
Hyperbola Pascal Code