golib  0.5
goNUBS Class Reference

Cubic Non-uniform non-rational B-spline approximation. More...

#include <gonurbs.h>

Public Member Functions

 goNUBS (const goCurvef *curve)
 Constructor. More...
 
 goNUBS (const goCurved *curve)
 Constructor. More...
 
goDouble getCurveLength () const
 Get curve length. More...
 
bool calculate ()
 Calculate with current control points. More...
 
bool setControlPoints (const goList< goPointf > &points)
 Calculate with given point list. More...
 
bool setControlPoints (const goList< goPointd > &points)
 
bool setControlPoints (goList< goPointf >::ConstElement *begin, goList< goPointf >::ConstElement *end, bool closed=false)
 Set control points to given point list. More...
 
bool setControlPoints (goList< goPointd >::ConstElement *begin, goList< goPointd >::ConstElement *end, bool closed=false)
 
bool setControlPoints (goList< goPointf >::ConstElement *begin, goIndex_t count, bool closed=false)
 Set control points to given point list. More...
 
bool setControlPoints (goList< goPointd >::ConstElement *begin, goIndex_t count, bool closed=false)
 Set control points to given point list. More...
 
goPointf operator() (goFloat u)
 Evaluate the B-spline curve at u. More...
 
 goNUBS (const goCurvef *curve)
 
 goNUBS (const goCurved *curve)
 
goDouble getCurveLength () const
 
bool calculate ()
 
bool setControlPoints (const goList< goPointf > &points)
 
bool setControlPoints (const goList< goPointd > &points)
 
bool setControlPoints (goList< goPointf >::ConstElement *begin, goList< goPointf >::ConstElement *end, bool closed=false)
 
bool setControlPoints (goList< goPointd >::ConstElement *begin, goList< goPointd >::ConstElement *end, bool closed=false)
 
bool setControlPoints (goList< goPointf >::ConstElement *begin, goIndex_t count, bool closed=false)
 
bool setControlPoints (goList< goPointd >::ConstElement *begin, goIndex_t count, bool closed=false)
 
goPointf operator() (goFloat u)
 

Detailed Description

Cubic Non-uniform non-rational B-spline approximation.

Uses cubic NUBS to approximate a curve. A curve can either be given in the constructor as a goCurve* or as a goList<goPointf> to setControlPoints(). In order to get knots with multiplicity > 0, define points with the desired multiplicity. If you want periodic functions (closed curves), append the first point of the curve at its end. That's not tested, but should suffice.

Todo:

B is currently calculated recursively. Use de Boor instead.

Currently this class is not compiled. Replace the use of goPoint with goMath::Vector.

Author
Christian Gosch

Uses cubic NUBS to approximate a curve. A curve can either be given in the constructor as a goCurve* or as a goList<goPointf> to setControlPoints(). In order to get knots with multiplicity > 0, define points with the desired multiplicity. If you want periodic functions (closed curves), append the first point of the curve at its end. That's not tested, but should suffice.

Todo:
B is currently calculated recursively. Use de Boor instead.
Author
Christian Gosch

Constructor & Destructor Documentation

◆ goNUBS() [1/2]

goNUBS::goNUBS ( const goCurvef curve)

Constructor.

Parameters
curvePointer to the curve object. If 0, no action is taken. If != 0, the curve is approximated and operator() can be used to evaluate the curve. The valid parameter range is [0,getCurveLength()).

◆ goNUBS() [2/2]

goNUBS::goNUBS ( const goCurved curve)

Constructor.

Parameters
curvePointer to the curve object. If 0, no action is taken. If != 0, the curve is approximated and operator() can be used to evaluate the curve. The valid parameter range is [0,getCurveLength()).

Member Function Documentation

◆ calculate()

bool goNUBS::calculate ( )

Calculate with current control points.

Basically only calculates the knot values.

◆ getCurveLength()

goDouble goNUBS::getCurveLength ( ) const

Get curve length.

The valid parameter range for operator() can be determined with this function and is [0,getCurveLength()).

Returns
The curve length.

◆ operator()()

goPointf goNUBS::operator() ( goFloat  u)

Evaluate the B-spline curve at u.

Note
Note that parameter u must be in a half-open interval. If you request nubs.operator()(nurbs.getCurveLength()), you will get (0,0,0) as an answer. E.g., nurbs.operator(nurbs.getCurveLength() - 1e-5) results in something close to the curve's end.
Todo:

If it nags someone too much, return the end point when nubs.operator()(nurbs.getCurveLength()) is requested.

Currently intervals are searched for linearly. Improve that when there's time.

Store the control points in an array additionally to speed up access.

Parameters
uPoint to evaluate at. Must be in [ 0,getCurveLength() ). Note the half-open interval.
Returns
Point at u. (0,0,0) by default, e.g. if u is out of range.

◆ setControlPoints() [1/4]

bool goNUBS::setControlPoints ( const goList< goPointf > &  points)

Calculate with given point list.

Copies points to the internal point list, adds the last point twice and calls calculate().

Parameters
pointsThe point list describing the curve to be approximated.
Returns
True if successful, false otherwise.

◆ setControlPoints() [2/4]

bool goNUBS::setControlPoints ( goList< goPointd >::ConstElement *  begin,
goIndex_t  count,
bool  closed = false 
)

Set control points to given point list.

Copies points to the internal point list, adds the last point twice and calls calculate().

Parameters
pointsThe point list describing the curve to be approximated.
Returns
True if successful, false otherwise.

◆ setControlPoints() [3/4]

bool goNUBS::setControlPoints ( goList< goPointf >::ConstElement *  begin,
goIndex_t  count,
bool  closed = false 
)

Set control points to given point list.

Copies points to the internal point list, adds the last point twice and calls calculate().

Parameters
pointsThe point list describing the curve to be approximated.
Returns
True if successful, false otherwise.

◆ setControlPoints() [4/4]

bool goNUBS::setControlPoints ( goList< goPointf >::ConstElement *  begin,
goList< goPointf >::ConstElement *  end,
bool  closed = false 
)

Set control points to given point list.

Copies points to the internal point list, adds the last point twice and calls calculate().

Parameters
pointsThe point list describing the curve to be approximated.
Returns
True if successful, false otherwise.

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