Home > Degrafa, Flex > Automatic Bezier Arcs in Degrafa

Automatic Bezier Arcs in Degrafa

June 30, 2010

An interesting problem is to draw an eye-pleasing arc between two points.  This can be used for anything from drawing origin-destination route arcs to approximating trajectories in animation.  Since we already know how to interpolate a quadratic Bezier between three points, one possible solution is to parameterize the generation of a middle interpolation point given two initial points.

I’ve used an algorithm along these lines since about 1982.  It takes two parameters, one of which determines the concavity of the arc.  The second parameter controls the distance between the midpoint of the line segment from first to last point and the middle interpolation point.  This provides a large amount of control over the generated arc.

A closely related problem is animating the arc.  This is trivial with a quadratic Bezier as the section of arc at any parameter value can be drawn with a single curveTo command using deCasteljau subdivision.

The auto-arc generation is now in the BezierUtils class and the subdivision method has been added to the AdvancedQuadraticBezier class.  A screen shot from the rather plain and simple demo is shown below.

Quadratic Bezier auto-fit between two points

The code has been checked into the Origin branch.

View demo.

View source.

Advertisements
Categories: Degrafa, Flex Tags: , , ,
%d bloggers like this: