SLProject 4.0.000
|
The SLCurveBezier class implements a Bezier curve interpolation. More...
#include <SLCurveBezier.h>
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 () |
SLVVec3f & | controls () |
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... | |
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.
SLCurveBezier::SLCurveBezier | ( | const SLVVec4f & | points | ) |
SLCurveBezier::~SLCurveBezier | ( | ) |
SLCurveBezier::curveAcceleration determines the acceleration vector on the curve at time t. It is the second derivative at point t.
Calculate length of curve between parameters t1 and t2
|
inline |
|
virtual |
Deletes all curve arrays.
Implements SLCurve.
|
virtual |
SLCurveBezier::draw does the rendering of the Bezier curve in world space.
Implements SLCurve.
SLCurveBezier::curveEvaluate determines the position on the curve at time t.
Implements SLCurve.
SLCurveBezier::findParamByDist gets parameter s distance in arc length from Q(t1). Returns max SLfloat if can't find it.
Init curve with curve points and times. If no control points are passed they will be calculated automatically
points | Array of points on the Bezier curve (w = time) |
controlPoints | Array of control points with size = 2*(numPointsAndTimes-1) |
|
inline |
SLCurveBezier::segmentArcLength calculate length of curve segment between parameters u1 and u2 by recursively subdividing the segment.
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.
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.
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.
|
protected |
Control points of Bezier curve.
|
protected |
Vertex array object for rendering.