Flex for Business Decision Analytics

I’ve been asked a lot about what’s next for Singularity.  The parameteric curve library seems to be pretty  far along, so I need to go back and try to finish off the 2D rigging classes.  In tandem with that effort, I’ve decided to revive an old background project for which Flex seems to be much better suited than Flash.  Adobe has made some noise about using Flex for business intelligence, but only in terms of displaying dashboards.  A dashboard is driven by analysis of data which could range from simple statistics to advanced methodologies from the field of Operations Research.

In terms of the latter, Flex/AS 3 is well suited for model assembly and analysis, while FDS/RPC in tandem with suitable server-side software can handle the solution of OR models.  So, the big question is how do you put it all together?  I guess I’m going to have fun working up some demos 🙂

For some light bedtime reading,

Managing Supply-Chain Risk
Multiobjective Programming
Lagrangian Relaxation

Bezier Tweening and Velocity

Someone once remarked to me that tweening with Bezier curves seemed to have a ‘natural’ easing.  In some cases, a sprite moving along the curve might appear to move slowly out of the first control point, noticeably speeding up moving into the last control point.

The issue is not easing, but parameterization.  The subject of parameterization has been dealt with in detail in this blog and in TechNotes, although mostly for composite curves. The Singularity Bezier curves now support approximate arc-length parameterization (implemented in the base Parametric class).

A person drawing a quadratic Bezier with curveTo() might be inclined to state that the point corresponding to t=0.5 was exactly halfway along the length of the Bezier curve. If markers were distributed at say t=0, t=0.1, t=0.2 … t=1, one might expect them to be uniformly distributed along the curve.

In fact, the marker distribution depends on the curve’s geometric constraints (control point placement).  This is illustrated in the following screen shot,

The blue markers illustrate marker placement at natural (t-parameter) intervals, with a delta of 0.1 .  The green markers are placed at uniform normalized arc-length, i.e. s=0, s=0.1, s=0.2 … s=1.  Notice that the blue markers are closer together near the left-most part of the curve (knots were placed left-to-right) and farther apart near the right-most part of the curve.

A sprite animated along this curve using the natural parameterization would appear to move faster as it approached the final control point, leading to the impression of implicit easing.

The online demo may be viewed here.  I should point out that the algorithm for arc-length parameterization is based on spline interpolation and is only approximate.  There are some extreme conditions (highly acute control cage angles) in which the green marker spread is very slightly inconsistent.  Recent improvements in the arcLengthAt() estimation have alleviated this issue and the interpolation will be eliminated in an future release of the Singularity package.

Thanks to Zeh Fernando for his help in some initial testing!

Spline to XML MaxScript

The post on exporting splines to XML for path animation in Papervision 3D proved to be pretty popular 🙂  I’ve received some requests for the Maxscript used in the export.  It’s pretty pathetic as scripts go, but here you go!

Place the script in the {3ds max root}/scripts folder.  Run the SplineToXML.ms script, then open a listener window.  Select a curve in MAX.  In the listener window, type


Move the camerapath.xml file from the scripts folder to the bin folder of your Flex app.  Animate and have fun!

Caveat:  My 3ds max install is very old (V6), so I can’t vouch that the script runs on later versions of the software.

Papervision 3D Path Animation from 3ds max

The previous experiments with path animation in Papervision 3D were interesting, but of little practical use as very few applications generate path information programmatically at runtime.  A more common workflow is to generate paths in a 3d application.  The latest addition to the Singularity parametric curve library is a 3D Bezier spline that is suitable for working with cubic spline paths generated from other applications.

The 2D bezier spline took knots (or CV’s) as inputs and automatically generated tangents.  The 3D version simply accepts CV, in-, and out-tangent information generated from a 3D package.  To test this spline with 3ds max, I wrote a simple MAXScript to export spline data to XML.  A Flex program reads the XML data (E4X is very cool) and transfers the data to the 3D Bezier spline.  An example is shown below,

whose exported XML is

<spline name=’Line01′ knots=’7′ closed=’true’>
 <knot x=’-123.018′ y=’53.5028′ z=’0.0′>
 <invec x=’-154.627′ y=’16.1465′ z=’0.0′ />
 <outvec x=’-91.4084′ y=’90.8591′ z=’0.0′ />
 <knot x=’-7.033′ y=’88.4169′ z=’-91.3649′>
 <invec x=’-77.1479′ y=’83.8192′ z=’-91.3649′ />
 <outvec x=’63.0819′ y=’93.0146′ z=’-91.3649′ />
 <knot x=’110.694′ y=’89.7132′ z=’0.0′>
 <invec x=’80.1177′ y=’107.975′ z=’0.0′ />
 <outvec x=’141.27′ y=’71.4514′ z=’0.0′ />
 <knot x=’161.098′ y=’-13.6597′ z=’0.0′>
 <invec x=’166.459′ y=’30.5072′ z=’0.0′ />
 <outvec x=’155.736′ y=’-57.8267′ z=’0.0′ />
 <knot x=’61.2687′ y=’-93.0454′ z=’-91.3649′>
 <invec x=’100.924′ y=’-86.7235′ z=’-91.3649′ />
 <outvec x=’21.6135′ y=’-99.3672′ z=’-91.3649′ />
 <knot x=’-49.5287′ y=’-89.2301′ z=’-91.3649′>
 <invec x=’-2.977′ y=’-116.816′ z=’-91.3649′ />
 <outvec x=’-96.0804′ y=’-61.6439′ z=’-91.3649′ />
 <knot x=’-154.02′ y=’-41.2029′ z=’0.0′>
 <invec x=’-145.71′ y=’-73.8184′ z=’0.0′ />
 <outvec x=’-162.33′ y=’-8.58747′ z=’0.0′ />

The online Papervision 3D demo contains two cameras. The first camera (static view) allows a marker to be visualized moving along the path. Since the Cubic Bezier spline supports arc-length parameterization, the marker moves along the path at constant velocity. The second camera is animated and looks at the origin from the point of view of the marker.

View the online demo here, which includes a link to download the Singularity package.