C# Class Nez.Splines.BezierSpline

houses a series of cubic bezier points and provides helper methods to access the bezier
Datei anzeigen Open project: prime31/Nez Class Usage Examples

Public Methods

Method Description
addCurve ( Vector2 start, Vector2 firstControlPoint, Vector2 secondControlPoint, Vector2 end ) : void

adds a curve to the bezier

getDirectionAtTime ( float t ) : Vector2

gets the direction (normalized first derivative) of the bezier at time t

getDrawingPoints ( int totalSegments ) : Microsoft.Xna.Framework.Vector2[]

breaks up the spline into totalSegments parts and returns all the points required to draw using lines

getPointAtTime ( float t ) : Vector2

gets the point on the bezier at time t

getVelocityAtTime ( float t ) : Vector2

gets the velocity (first derivative) of the bezier at time t

reset ( ) : void

resets the bezier removing all points

setControlPoint ( int index, Vector2 point ) : void

sets a control point taking into account if this is a shared point and adjusting appropriately if it is

Private Methods

Method Description
pointIndexAtTime ( float &t ) : int

helper that gets the bezier point index at time t. t is modified in the process to be in the range of the curve segment.

Method Details

addCurve() public method

adds a curve to the bezier
public addCurve ( Vector2 start, Vector2 firstControlPoint, Vector2 secondControlPoint, Vector2 end ) : void
start Microsoft.Xna.Framework.Vector2 Start.
firstControlPoint Microsoft.Xna.Framework.Vector2 First control point.
secondControlPoint Microsoft.Xna.Framework.Vector2 Second control point.
end Microsoft.Xna.Framework.Vector2
return void

getDirectionAtTime() public method

gets the direction (normalized first derivative) of the bezier at time t
public getDirectionAtTime ( float t ) : Vector2
t float T.
return Microsoft.Xna.Framework.Vector2

getDrawingPoints() public method

breaks up the spline into totalSegments parts and returns all the points required to draw using lines
public getDrawingPoints ( int totalSegments ) : Microsoft.Xna.Framework.Vector2[]
totalSegments int Total segments.
return Microsoft.Xna.Framework.Vector2[]

getPointAtTime() public method

gets the point on the bezier at time t
public getPointAtTime ( float t ) : Vector2
t float T.
return Microsoft.Xna.Framework.Vector2

getVelocityAtTime() public method

gets the velocity (first derivative) of the bezier at time t
public getVelocityAtTime ( float t ) : Vector2
t float T.
return Microsoft.Xna.Framework.Vector2

reset() public method

resets the bezier removing all points
public reset ( ) : void
return void

setControlPoint() public method

sets a control point taking into account if this is a shared point and adjusting appropriately if it is
public setControlPoint ( int index, Vector2 point ) : void
index int Index.
point Microsoft.Xna.Framework.Vector2 Point.
return void