Packagesandy.util
Classpublic class BezierUtil

Utility class for Bézier calculations.

All credits go to Alex Ulhmann and his Animation Package Library



Public Methods
 MethodDefined by
  
casteljau(p:Number, plist:Array):Vector
[static] Applies the de Casteljau's algorithm.
BezierUtil
  
casteljau_interval(p:Number, plist:Array, pdeb:Number, pfin:Number):Vector
[static] Applies a more robust de Casteljau's algorithm if the intervals are "wierd".
BezierUtil
  
getCubicControlPoints(start:Vector, through1:Vector, through2:Vector, end:Vector):Array
[static] Returns the control points for a qubic Bézier curve.
BezierUtil
  
[static] Returns a point on a qubic Bézier curve.
BezierUtil
  
[static] Returns a point on a quadratic Bézier curve.
BezierUtil
  
[static] Returns the control point for a quadratic Bézier curve.
BezierUtil
Method detail
casteljau()method
public static function casteljau(p:Number, plist:Array):Vector

Applies the de Casteljau's algorithm.

[ToDo: Better explanations - link to wikipedia ]

Parameters
p:Number — A fraction between [0-1] of the whole curve
 
plist:Array — The list of control points of the Bézier curve.

Returns
Vector — The position on the Bézier curve at the fraction p of the curve.
casteljau_interval()method 
public static function casteljau_interval(p:Number, plist:Array, pdeb:Number, pfin:Number):Vector

Applies a more robust de Casteljau's algorithm if the intervals are "wierd".

UNTESTED METHOD. MAY BE REMOVED IN THE FUTURE VERSION. USE IT CAREFULLY.

[ToDo: Better explanations - link to wikipedia ]

Parameters
p:Number — A fraction between [0-1] of the whole curve
 
plist:Array — The list of control points of the Bézier curve.
 
pdeb:Number
 
pfin:Number

Returns
Vector — The position on the Bézier curve at the fraction p of the curve.
getCubicControlPoints()method 
public static function getCubicControlPoints(start:Vector, through1:Vector, through2:Vector, end:Vector):Array

Returns the control points for a qubic Bézier curve.

If anybody finds a generic method to compute control points for bezier curves with n control points, if only the points on the curve are given, please let us know!

Parameters
start:Vector — The start point of the curve
 
through1:Vector — The second point
 
through2:Vector — The third point
 
end:Vector — The end point

Returns
Array — A two dimensional array containing the two controls points.
getPointsOnCubicCurve()method 
public static function getPointsOnCubicCurve(p:Number, p1:Vector, p2:Vector, p3:Vector, p4:Vector):Vector

Returns a point on a qubic Bézier curve.

Adapted from Paul Bourke.

Parameters
p:Number — A fraction between [0-1] of the whole curve
 
p1:Vector — First point
 
p2:Vector — Second point
 
p3:Vector — Third point
 
p4:Vector — Fourth point

Returns
Vector — The resulting position vector
getPointsOnQuadCurve()method 
public static function getPointsOnQuadCurve(p:Number, p1:Vector, p2:Vector, p3:Vector):Vector

Returns a point on a quadratic Bézier curve.

Adapted from Robert Penner
with Robert Penner's optimization of the standard equation.

Parameters
p:Number — A fraction between [0-1] of the whole curve
 
p1:Vector — First point
 
p2:Vector — Second point
 
p3:Vector — Third point

Returns
Vector — The resulting position vector
getQuadControlPoints()method 
public static function getQuadControlPoints(start:Vector, middle:Vector, end:Vector):Vector

Returns the control point for a quadratic Bézier curve.

Adapted from Robert Penner's drawCurve3Pts() method

Parameters
start:Vector — The start point of the curve
 
middle:Vector — The middle point
 
end:Vector — The end point

Returns
Vector — The control point