Site Archive (Complete)
Java
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
TABLE OF CONTENTS
July 25, 2008
Ellipse Specification Using Vectors

An alternative method for rendering ellipses

(Page 1 of 3)
Robert F. Kauffmann
The program Robert presents here demonstrates a method for rendering ellipses that's suited to the specific task of aligning ellipses to arbitrary curve segments using trigonometric splines.
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.

Figure 1: "Eyeballing" placement of the nearest corner of the bounding box.

Figure 2: Approximating with a vector-based ellipse.

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.

1 Bounding Box Ellipses | 2 Trigonometric Splines | 3 Rendering Ellipses Next Page
TOP 5 ARTICLES
No Top Articles.
DR. DOBB'S CAREER CENTER
Ready to take that job and shove it? open | close
Search jobs on Dr. Dobb's TechCareers
Function:

Keyword(s):

State:  
  • Post Your Resume
  • Employers Area
  • News & Features
  • Blogs & Forums
  • Career Resources

    Browse By:
    Location | Employer | City
  • Most Recent Posts:



    MICROSITES
    FEATURED TOPIC

    ADDITIONAL TOPICS

    INFO-LINK



     



    Related Sites: DotNetJunkies, SD Expo, SqlJunkies