<docbook><section><title>OATDOCbezier</title><para> </para>
<title> bezier.js</title> bezier.js
<para>Provides two mathematical functions for drawing Bezier curves.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Functions</bridgehead>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.Bezier.setPointList(pointList)</bridgehead>
<para>Marks an array of 2D points as a base for a Bezier curve.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.Bezier.initFactorial(max)</bridgehead>
<para>Pre-computes factorials of <computeroutput>1..max</computeroutput> for later execution.
 Call this function once, in the initialization part of your script.
 This speeds up creation of bezier curves using <computeroutput>OAT.Bezier.create2()</computeroutput> function.
 Set the max argument to the number of points.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.Bezier.create()</bridgehead>
<para>Returns a Bezier functionf: <computeroutput>[0,1] -&gt; R^2</computeroutput> which describes parametric Bezier curve, based on points set by <computeroutput>OAT.Bezier.setPointList()</computeroutput>.</para>
<para>Uses slow but precise recursive <ulink url="http://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm">de Casteljau&#39;s algorithm</ulink>.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> OAT.Bezier.create2()</bridgehead>
<para>Returns a Bezier functionf: <computeroutput>[0,1] -&gt; R^2</computeroutput> which describes parametric Bezier curve, based on points set by <computeroutput>OAT.Bezier.setPointList()</computeroutput>.</para>
<para>Uses faster factorial algorithm based directly on <ulink url="http://en.wikipedia.org/wiki/Bernstein_polynomial">Bernstein polynomials</ulink>.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Example</bridgehead>
<programlisting>var points = [];
points.push([0,0]);
points.push([1,0]);
points.push([1,1]);
OAT.Bezier.setPointList(points);
var f = OAT.Bezier.create2();
alert(f(0.5)); // [x, y] where x in [0,1], y in [0,1]
</programlisting><para> <ulink url="CategoryDocumentation">CategoryDocumentation</ulink> <ulink url="CategoryOAT">CategoryOAT</ulink> <ulink url="CategoryOpenSource">CategoryOpenSource</ulink></para>
</section></docbook>