SLProject 4.0.000
SLCurveBezier Class Reference

The SLCurveBezier class implements a Bezier curve interpolation. More...

#include <SLCurveBezier.h>

Inheritance diagram for SLCurveBezier:
[legend]

Public Member Functions

 SLCurveBezier (const SLVVec4f &points)
 
 SLCurveBezier (const SLVVec4f &points, const SLVVec3f &controlPoints)
 
 ~SLCurveBezier ()
 
void dispose ()
 Deletes all curve arrays. More...
 
void init (const SLVVec4f &points, const SLVVec3f &controlPoints)
 
void draw (const SLMat4f &wm)
 
SLVec3f evaluate (const SLfloat t)
 
SLVec3f velocity (SLfloat t)
 
SLVec3f acceleration (SLfloat t)
 
SLfloat segmentArcLength (SLuint i, SLfloat u1, SLfloat u2)
 
SLfloat subdivideLength (const SLVec3f &P0, const SLVec3f &P1, const SLVec3f &P2, const SLVec3f &P3)
 
void subdivideRender (SLVVec3f &points, const SLMat4f &wm, SLfloat epsilon, const SLVec3f &P0, const SLVec3f &P1, const SLVec3f &P2, const SLVec3f &P3)
 
SLfloat arcLength (SLfloat t1, SLfloat t2)
 
SLfloat findParamByDist (SLfloat t1, SLfloat s)
 
SLint numControlPoints ()
 
SLVVec3fcontrols ()
 
- Public Member Functions inherited from SLCurve
 SLCurve ()
 
virtual ~SLCurve ()
 
virtual void dispose ()=0
 
virtual SLVec3f evaluate (const SLfloat t)=0
 
virtual void draw (const SLMat4f &wm)=0
 

Protected Attributes

SLVVec3f _controls
 Control points of Bezier curve. More...
 
SLGLVertexArrayExt _vao
 Vertex array object for rendering. More...
 
- Protected Attributes inherited from SLCurve
SLVVec4f _points
 Sample points (x,y,z) and time (w) of curve. More...
 
SLVfloat _lengths
 Length of each curve segment. More...
 
SLfloat _totalLength
 Total length of curve. More...
 

Detailed Description

The SLCurveBezier class implements a Bezier curve interpolation.

The SLCurveBezier class implements a Bezier curve interpolation. The math is originally based on the implementation from the book: "Essential Mathematics for Games and Interactive Applications" from James M. Van Verth and Lars M. Bishop.

Constructor & Destructor Documentation

◆ SLCurveBezier() [1/2]

SLCurveBezier::SLCurveBezier ( const SLVVec4f points)

◆ SLCurveBezier() [2/2]

SLCurveBezier::SLCurveBezier ( const SLVVec4f points,
const SLVVec3f controlPoints 
)

◆ ~SLCurveBezier()

SLCurveBezier::~SLCurveBezier ( )

Member Function Documentation

◆ acceleration()

SLVec3f SLCurveBezier::acceleration ( SLfloat  t)

SLCurveBezier::curveAcceleration determines the acceleration vector on the curve at time t. It is the second derivative at point t.

◆ arcLength()

SLfloat SLCurveBezier::arcLength ( SLfloat  t1,
SLfloat  t2 
)

Calculate length of curve between parameters t1 and t2

◆ controls()

SLVVec3f & SLCurveBezier::controls ( )
inline

◆ dispose()

void SLCurveBezier::dispose ( )
virtual

Deletes all curve arrays.

Implements SLCurve.

◆ draw()

void SLCurveBezier::draw ( const SLMat4f wm)
virtual

SLCurveBezier::draw does the rendering of the Bezier curve in world space.

Implements SLCurve.

◆ evaluate()

SLVec3f SLCurveBezier::evaluate ( const SLfloat  t)
virtual

SLCurveBezier::curveEvaluate determines the position on the curve at time t.

Implements SLCurve.

◆ findParamByDist()

SLfloat SLCurveBezier::findParamByDist ( SLfloat  t1,
SLfloat  s 
)

SLCurveBezier::findParamByDist gets parameter s distance in arc length from Q(t1). Returns max SLfloat if can't find it.

◆ init()

void SLCurveBezier::init ( const SLVVec4f points,
const SLVVec3f controlPoints 
)

Init curve with curve points and times. If no control points are passed they will be calculated automatically

Parameters
pointsArray of points on the Bezier curve (w = time)
controlPointsArray of control points with size = 2*(numPointsAndTimes-1)

◆ numControlPoints()

SLint SLCurveBezier::numControlPoints ( )
inline

◆ segmentArcLength()

SLfloat SLCurveBezier::segmentArcLength ( SLuint  i,
SLfloat  u1,
SLfloat  u2 
)

SLCurveBezier::segmentArcLength calculate length of curve segment between parameters u1 and u2 by recursively subdividing the segment.

◆ subdivideLength()

SLfloat SLCurveBezier::subdivideLength ( const SLVec3f P0,
const SLVec3f P1,
const SLVec3f P2,
const SLVec3f P3 
)

SLCurveBezier::subdivideLength calculates length of Bezier curve by recursive midpoint subdivision.

◆ subdivideRender()

void SLCurveBezier::subdivideRender ( SLVVec3f renderPoints,
const SLMat4f wm,
SLfloat  epsilon,
const SLVec3f P0,
const SLVec3f P1,
const SLVec3f P2,
const SLVec3f P3 
)

SLCurveBezier::subdivideRender adds points along the curve to the point vector renderPoints by recursively subdividing the curve with the Casteljau scheme.

◆ velocity()

SLVec3f SLCurveBezier::velocity ( SLfloat  t)

SLCurveBezier::curveVelocity determines the velocity vector on the curve at point t. The velocity vector direction is the tangent vector at t an is the first derivative at point t. The velocity vector magnitude is the speed at point t.

Member Data Documentation

◆ _controls

SLVVec3f SLCurveBezier::_controls
protected

Control points of Bezier curve.

◆ _vao

SLGLVertexArrayExt SLCurveBezier::_vao
protected

Vertex array object for rendering.


The documentation for this class was generated from the following files: