*Robert is a software engineer and award-winning independent animator. He can be reached at mathart63@gmail.com.*

Over the years, I've made heavy use of graphical editing programs and sometimes needed to use ellipse drawing functions. What I've found is that ellipse drawing functions in graphical editing programs typically use bounding boxes for specifying ellipses. This method serves well if the task requires fitting the ellipse within the confines of a box, or if it's not necessary to align the edge of the ellipse with precision. On occasion, however, I've had a need to use an ellipse (or a portion thereof) to approximate a freeform curve. In such cases, bounding boxes serve poorly. Why? Because the outer corner of the bounding box that specifies the ellipse is far enough away from the curve of interest that "eyeballing" placement of the nearest corner of the bounding box to specify an ellipse that approximates the freeform curve is error prone and usually produces erroneous results, as in Figure 1.

The problem is that ellipse curves specified by bounding boxes are physically disconnected from the opposite corners of the box that are actually under user control. This physical disconnect robs users of the ability to place the edge of the ellipse precisely against the freeform curve of interest. To give users the control needed to produce ellipses that approximate the curvature of a freeform curve, it is more expedient to specify an ellipse using points that interpolate (lie on the actual ellipse) rather than exterpolate (in which the ellipse is tied to the points but detached from them). This lets users click directly on the curve and anchor the ellipse to the freeform curve of interest from the outset. One approach is to specify an ellipse from a vector the user specifies. In Figure 2, the user clicks on some point lying upon the freeform curve and drags the end of the vector—along with the corresponding ellipse—until it closely approximates the freeform curve.

You can implement this scheme using a uniform interpolating trigonometric spline (TSpline) whose control points lie at the corners of a rectangle. Alternatively, you can use the corners of a rhombus (see "Implementing Uniform Trigonometric Spline Curves"; www.ddj.com/architect/184410198). Both approaches inscribe (rather than circumscribe) the ellipse. In either case, a single vector is sufficient to define the four control points that specify an ellipse formed of a TSpline. For this algorithm, the most practical choice is to implement the TSpline ellipse that is specified by an inscribed rectangle.