next up previous contents
Next: Definitions Up: Drawing an elliptical arc Previous: Contents   Contents

Introduction

When dealing with three dimensional geometry, one often needs to draw some sketch with circles or arcs seen from an arbitrary point of view. They appear as ellipses and arcs of ellipses when displayed on a two dimensions plane such as paper or screen. The classical graphical languages or libraries provide primitives for drawing several objects like rectangles or circles. Lot of them can also handle ellipses, but only when their axes are aligned with the device axes, and sometimes only for complete ellipses (with the notable exception of SVG which has two commands, A and a, to add a general ellipse arc to the current path)

Hence, drawing these objects involve dealing with low level graphics. An algorithm based on Bresenham's principles has been published in the Foley and Van Dam book, it has been implemented by Andrew W. Fitzgibbon in C++ and is available with the PC Games Programmers Encyclopedia library (pcgpe) version 1.02, in the conic.cc file. The same file can be viewed online3. Unfortunately, one needs both good starting and ending points, i.e. exactly the same pixels the algorithm would have chosen by itself. Failing to do this result in strange spiral-like shapes. Another problem with such an algorithm is that it is at pixel level only and do not handle dashes or line width.

Another method is to use intermediate level objects like polylines or Bézier curves to approximate the ellipse. In this paper, we will describe how this can be done, depending on the available primitives and for any user defined accuracy.

Using these intermediate level curves has several advantages. The first one is that the user can often use his own coordinate system and use floating point numbers, he does not consider pixels at all. Another advantage is that the graphical packages handles high level features with such objects, like filling closed shapes, drawing with various pens (both pen shape and pen size can be customized) and drawing with various line styles (continuous lines, dashed lines with several dash patterns). Since each object can contain a lot of individual pixels, the description of the elliptical arc is also much shorter than specifying each pixel individually. Of course, for a given accuracy, polylines are less efficient than cubic Bézier curves for example, so the description size will depend on the available features of the underlying graphical package.

Three cases will be considered: lines (all graphical packages can handle them), quadratic Bézier curves (available for example in LATEX2e) and cubic Bézier curves (available in LATEX2e when the bez123 extension is loaded, METAFONT, PDF, PostScript, Java API, SVG ...).

The last version of this document is always available in the spaceroots downloads page http://www.spaceroots.org/downloads.html. It can be browsed on-line or retrieved as a PDF, compressed PostScript or LaTeX source file.


next up previous contents
Next: Definitions Up: Drawing an elliptical arc Previous: Contents   Contents
Luc Maisonobe 2005-05-29