Class sandy.core.data.BezierPath

Description

A 3D path interpolated with Bezier equations

A Bezier path is basically an array of 3D points, but the path is interpolated thanks to Bezier equations, allowing some nice movements

Method Index

new BezierPath()
addPoint(), compile(), getNumberOfSegments(), getPosition(), getSegment(), toString()

Constructor Detail

BezierPath

public function BezierPath()

Create a new BezierPath Instance.

Method Detail

getSegment

public function getSegment(pnId:Number):Array

Returns the segment that fits to the percentage number passed in arguments. You can imagine the whole path length as the 1.0 value (100%). Now if you need the segment when you are at only 10% of the whole path you just have to pass 0.1 in argument, and the returned array contain the bezierCurve points [startPoint, controlPoint, endPoint]

Parameters

pnId

Return

Array array containing the segment's bezierCurve points [startPoint, controlPoint, endPoint]

getPosition

public function getPosition(p:Number):Vector

Returns the position in the 3D space at a specific percentage. You can imagine the whole path length as the 1.0 value (100%). Now if you need the position when you are at only 10% of the whole path you just have to pass 0.1 in argument, and the returned value is the position on that percentage of the whole path.

Parameters

pNumber A percentage between [0-1]

Return

Vector The 3D position on the path at the current percentage.

addPoint

public function addPoint(x:Number, y:Number, z:Number):Boolean

Add a point to the path. WARNING : You can't add a point to the path once it has been compiled.

Parameters

xNumber
yNumber
zNumber

Return

Boolean true if operation succeed, false otherwise.

compile

public function compile(Void):Void

Computes all the control points. Must be called before being used by Sandy's engine. Should be called once tha last point of the path has been added.

Parameters

Void

getNumberOfSegments

public function getNumberOfSegments(Void):Number

returns the number of segments;

Parameters

Void

Return

Number the number of segments

toString

public function toString(Void):String

Get a String represntation of the BezierPath.

Return

A String representing the BezierPath.