Charles Petzold

Squaring the Circle

April 22, 2006
A rainy New York City Saturday

Oh, well, another millennia-old geometry problem solved with a few lines of XAML.

But seriously, folks, this program shows how the individual end points and control points of Bézier curves can be animated. A circle is approximated with four Bézier curves. (See pages 629-632 of Programming Windows with C# for details on the technique.) The 13 points are animated between the circle values and those necessary to define a square approximately equal in area. For the four sides of the square, the Béziers collapse into straight lines when the two control points lie on the straight line between the two end points.