Home > Flash, Math > Elliptical Arcs for Aribtrarily Rotated Ellipse

Elliptical Arcs for Aribtrarily Rotated Ellipse

August 26, 2009

I’ve received a few requests over the last several weeks for methods to approximate elliptical arcs with quad. Beziers for an ellipse that is rotated at an arbitrary angle.  Further, the requests were for straight actionscript; no Flex and no Degrafa.  Oh well, not as fun, but your wish is my command 🙂

I originally worked with this algorithm for a cubic Bezier approximation in a computational geometry class in 1981.  I don’t have an original attribution for the algorithm, but suspect it goes back to the 1970’s.  Fortunately, the quad. case is easier, although strict error analysis is still tricky.  For ellipses with major/minor axes of a few hundred px, it seems that approximating the arc in segments spanning no more than PI/8 is an acceptable starting heuristic.  You may need something more sophisticated for much larger cases.

A screenshot of the demo (Flash CS3) is shown below.  The code is straight AS on the timeline; no frills, no classes, just a straightforward implementation of the algorithm.

Approximating an arc of a rotated ellipse

Approximating an arc of a rotated ellipse

The code draws a simple wedge.  You can download it here.  If there is sufficient interest, I might incorporate this into Degrafa (whose elliptical arc class does not take rotation into account if memory serves).

Enjoy!

Categories: Flash, Math Tags: , , , ,
  1. JT
    August 26, 2009 at 9:48 am

    Ha – thanks for reading your email.

    • August 26, 2009 at 9:53 am

      JT – I get about 60 emails a day (M-F) asking for help on everything from free consulting for Singularity to help on homework. I don’t even have time to respond to everyone telling them I don’t have time to respond 🙂

      My general rule is if something is asked for more than once, it’s math/geometry/Flash/Flex related, and probably can’t be quickly answered in a forum, then I’ll consider it for the blog.

      regards,

      – jim

  1. No trackbacks yet.
Comments are closed.
%d bloggers like this: