Archive for August, 2007

Lemniscate of Bernoulli

August 31, 2007 2 comments

Or, a fancy name for a figure-8 or infinty shape.  Some curves do not have simple, closed-form equations for plotting.  In rectangular coordinates, the equation for the Lemniscate of Bernoulli is (x^2 + y^2)^2 = a^2(x^2 – y^2) .  In polor form, the equation is r^2 = a^2cos(2t) .  Because of the radical and the range of the cosine function, the polar form is used in a principal quadrant.  Symmetry and reflection may be used to generate the remainder of the curve. 

What if we were required to animate sprites along the curve? 


Since a highly accurate plot is not desired, it is easy to sample the curve to generate control points for a closed-loop Catmull-Rom spline (automatic closure saves having to generate the final control point).  Arc-length parameterization assures smooth motion during the animation.

This is illustrated in an online demo, which you may view here.  The demo page includes a link to download the entire Singularity package.

Categories: Flex, Math

New Tweener Class from the.laboratory

August 29, 2007 1 comment

There is a new Tweener class at the laboratory (Eduardo Dias da Costa’s blog) along with some cool demos.  I particularly liked the Catmull-Rom tween 🙂  Check it out here.

Categories: Flash, General

Path Animation with Papervision 3D

August 26, 2007 4 comments

I finally got around to implementing a 3D version of the Catmull-Rom spline.  My primary intended use is for path animation in Papervision 3D.  The 3D version of the C-R spline does not have the 2D draw() method, but it maintains support for arc-length parameterization and automatic closure (with smooth transition through the closure).

The former property is useful for velocity control and proper easing during path animation while the latter is useful for continuous fly-throughs.  An online demo is available, but be warned.  It is distilled down to a very simple level in order to make the code easier to understand. The result is probably the ugliest PV3D demo you will ever see 🙂

The red cubes represent markers, indicating control-point placement in 3D space.  The green sphere is animated (using arc-length parameterization) along the path.

Check out the online demo here, which includes a link to download the Singularity package (now containing the alpha 3D Catmull-Rom spline).

Categories: Flex, Math

AS 3 Optimizations

August 24, 2007 Comments off

John Grden started with a blog post on the topic of AS 3 optimization that has now grown into its own standalone page at . The new page also includes links to other experiments on the topic.  Check it out here and thanks to John for yet another great contribution to the Flash/Flex community!

Categories: Flash, Flex

Closed-Loop Catmull-Rom Spline

August 19, 2007 1 comment

Blogging has been slow the last couple weeks, dealing with gigs and migraines, but I found a little time to add closed-loop support to the Catmull-Rom spline. It’s a simple algorithm for adjusting the outer control points for a smooth transition through the first knot, as illustrated below.

The red marker indicates the first auxiliary control point. The green marker indicates the outermost auxiliary control point. The direction of the vector from initial knot to each control point is along the chord emanating from the first knot. The distance from first knot to both the second and next-to-last knots determines the distance along each chord to place the auxiliary control points. The first auxiliary control point is placed along the chord from the first knot to the next-to-last knot, but at a distance equal to that from the first to second knot. The process is reversed for the outermost auxiliary control point.

The graphic illustration should convince you of at least G-1 continuity. What would have to be modified for C-1? Although this approach is easy to illustrate and implement, it is not without issues. You are encouraged to download the code and experiment with different placement srategies for the outer control points.

Check out the online demo here, which includes a link to download the entire Singularity package.

Read the updated TechNote here.

Categories: Flex, Math

2A Jonathan Moore Interview

August 17, 2007 Comments off

Jonathan Moore of 2Advanced was recently interviewed at Behance.  Interesting stuff.  It’s often fun to take a break from applied math and see what’s going on inside the mind of the creative geniuses in the industry.  In case you have not noticed, PLAT4M is back with new content.  Enjoy!

Categories: General

Actionscript Convex Hull Class

August 2, 2007 1 comment

The last time I programmed a convex hull algorithm, it was waaaay back in the day when I was coding in Fortran — I’m a pathetic old dude.  Reviewing this example from Lost In Actionscript was a great way to end a hard day of application testing.

Check it out here.  I think Lost in Actionscript is one of my new favorite blogs.  It would be the top favorite if it played the LIS theme in the background 🙂

Categories: Flash, Math