Home > Flex > AS 3 Wedge Class

AS 3 Wedge Class

April 1, 2007

Approximating circular arcs with Bezier curves is a relatively simple process and is often a ‘rite of passage’ problem for first-semester computational geometry students. A quad. Bezier can reasonably approximate arcs of up to pi/4 radians. A cubic Bezier can reasonably approximate arcs of up to pi/2 radians. Higher-order curves can approximate semicircles, “Approximation of circular arcs by Bezier curves”, by Joon and Kim, Journal of Computational and Applied Mathematics 81 (1997), pp. 145-163.

I generally prefer to use Flex charting components for pie charts, but sometimes I need to draw a simple pie-shaped wedge and the components are serious overkill. A recent example is a graphic illustration of rotational joint limits for bones. A simple solution was a wedge class that uses a start point and start angle to define the base of a wedge. The wedge arc is broken into a number of equal-arc segments of no more than pi/4 radians. Each segment has a known start and end point. Some simple vector math is used to compute a middle interpolation point and a quad. Bezier is fit to the three points with the middle point at t=1/2 (textbook midpoint interpolation). This trades several sin/cos computations for a few extra flops and a sqrt.

The AS 3 version of the Wedge class has been added to the parametric curve library along with an interactive Flex driver. You may also download an AS 2 version here.

Not much to this one, but I hope it saves you a bit of effort some time in the future.

Categories: Flex
%d bloggers like this: