Visual Servoing Platform  version 3.6.1 under development (2024-12-17)

#include <visp3/me/vpNurbs.h>

+ Inheritance diagram for vpNurbs:

Public Member Functions

 vpNurbs ()
 
 vpNurbs (const vpNurbs &nurbs)
 
void get_weights (std::list< double > &list) const
 
void set_weights (const std::list< double > &list)
 
vpImagePoint computeCurvePoint (double u)
 
vpImagePointcomputeCurveDersPoint (double u, unsigned int der)
 
void curveKnotIns (double u, unsigned int s=0, unsigned int r=1)
 
void refineKnotVectCurve (double *x, unsigned int r)
 
unsigned int removeCurveKnot (double l_u, unsigned int l_r, unsigned int l_num, double l_TOL)
 
void globalCurveInterp (vpList< vpMeSite > &l_crossingPoints)
 
void globalCurveInterp (const std::list< vpImagePoint > &l_crossingPoints)
 
void globalCurveInterp (const std::list< vpMeSite > &l_crossingPoints)
 
void globalCurveInterp ()
 
void globalCurveApprox (vpList< vpMeSite > &l_crossingPoints, unsigned int n)
 
void globalCurveApprox (const std::list< vpImagePoint > &l_crossingPoints, unsigned int n)
 
void globalCurveApprox (const std::list< vpMeSite > &l_crossingPoints, unsigned int n)
 
void globalCurveApprox (unsigned int n)
 
unsigned int get_p () const
 
void get_controlPoints (std::list< vpImagePoint > &list) const
 
void get_knots (std::list< double > &list) const
 
void get_crossingPoints (std::list< vpImagePoint > &list) const
 
void set_p (unsigned int degree)
 
void set_controlPoints (const std::list< vpImagePoint > &list)
 
void set_knots (const std::list< double > &list)
 
void set_crossingPoints (const std::list< vpImagePoint > &list)
 
unsigned int findSpan (double u) const
 
vpBasisFunction * computeBasisFuns (double u) const
 
vpBasisFunction ** computeDersBasisFuns (double u, unsigned int der) const
 
vpImagePoint computeCurvePoint (double u) const
 
vpImagePointcomputeCurveDers (double u, unsigned int der) const
 

Static Public Member Functions

static vpImagePoint computeCurvePoint (double l_u, unsigned int l_i, unsigned int l_p, std::vector< double > &l_knots, std::vector< vpImagePoint > &l_controlPoints, std::vector< double > &l_weights)
 
static vpImagePointcomputeCurveDersPoint (double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der, std::vector< double > &l_knots, std::vector< vpImagePoint > &l_controlPoints, std::vector< double > &l_weights)
 
static void curveKnotIns (double l_u, unsigned int l_k, unsigned int l_s, unsigned int l_r, unsigned int l_p, std::vector< double > &l_knots, std::vector< vpImagePoint > &l_controlPoints, std::vector< double > &l_weights)
 
static void refineKnotVectCurve (double *l_x, unsigned int l_r, unsigned int l_p, std::vector< double > &l_knots, std::vector< vpImagePoint > &l_controlPoints, std::vector< double > &l_weights)
 
static unsigned int removeCurveKnot (double l_u, unsigned int l_r, unsigned int l_num, double l_TOL, unsigned int l_s, unsigned int l_p, std::vector< double > &l_knots, std::vector< vpImagePoint > &l_controlPoints, std::vector< double > &l_weights)
 
static void globalCurveInterp (std::vector< vpImagePoint > &l_crossingPoints, unsigned int l_p, std::vector< double > &l_knots, std::vector< vpImagePoint > &l_controlPoints, std::vector< double > &l_weights)
 
static void globalCurveApprox (std::vector< vpImagePoint > &l_crossingPoints, unsigned int l_p, unsigned int l_n, std::vector< double > &l_knots, std::vector< vpImagePoint > &l_controlPoints, std::vector< double > &l_weights)
 
static unsigned int findSpan (double l_u, unsigned int l_p, const std::vector< double > &l_knots)
 
static vpBasisFunction * computeBasisFuns (double l_u, unsigned int l_i, unsigned int l_p, const std::vector< double > &l_knots)
 
static vpBasisFunction ** computeDersBasisFuns (double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der, const std::vector< double > &l_knots)
 
static vpImagePoint computeCurvePoint (double l_u, unsigned int l_i, unsigned int l_p, const std::vector< double > &l_knots, const std::vector< vpImagePoint > &l_controlPoints)
 
static vpImagePointcomputeCurveDers (double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der, const std::vector< double > &l_knots, const std::vector< vpImagePoint > &l_controlPoints)
 

Protected Member Functions

vpMatrix computeCurveDers (double u, unsigned int der)
 

Static Protected Member Functions

static vpMatrix computeCurveDers (double l_u, unsigned int l_i, unsigned int l_p, unsigned int l_der, std::vector< double > &l_knots, std::vector< vpImagePoint > &l_controlPoints, std::vector< double > &l_weights)
 

Protected Attributes

std::vector< double > weights
 

Detailed Description

Class that provides tools to compute and manipulate a Non Uniform Rational B-Spline curve.

The different parameters are :

  • The knot vector $ U = {u_0, ... , u_m} $ where the knots $ u_i, i = 0, ...,m $ are real number such as $ u_i < u_{i+1} i = 0, ...,m $. To define a curve, the knot vector is such as : $ U = {a , ... , a, u_{p+1} , ... , u_{m-p-1} , b , ... , b} $ where $ a $ and $ b $ are real numbers and p is the degree of the B-Spline basis functions.
  • The B-Spline basis functions $ N_{i,p} $ defined as :

    \[ N_{i,0}(u) = \left\{\begin{array}{cc} 1 & \mbox{if } u_i \leq u_{i+1} \\ 0 & else \end{array}\right.\]

    \[ N_{i,p}(u) = \frac{u-u_i}{u_{i+p}-u_i}N_{i,p-1}(u)+\frac{u_{i+p+1}-u}{u_{i+p+1}-u_{i+1}}N_{i+1,p-1}(u)\]

where $ i = 0 , ... , m-1 $ and p is the degree of the B-Spline basis functions.

  • The control points $ {P_i} $ which are defined by the coordinates $ (i,j) $ of a point in an image.
  • The weight $ {w_i} $ associated to each control points. The weights value is upper than 0.

It is possible to compute the coordinates of a point corresponding to the knots $ u $ ( $ u \in [u_0,u_m]$) thanks to the formula :

\[ C(u) = \frac{\sum_{i=0}^n (N_{i,p}(u)w_iP_i)}{\sum_{i=0}^n (N_{i,p}(u)w_i)}\]

You can find much more information about the B-Splines and the implementation of all the methods in the Nurbs Book.

Examples
testNurbs.cpp.

Definition at line 92 of file vpNurbs.h.

Constructor & Destructor Documentation

◆ vpNurbs() [1/2]

vpNurbs::vpNurbs ( )

Basic constructor.

The degree $ p $ of the NURBS basis functions is set to 3 to compute cubic NURBS.

Definition at line 52 of file vpNurbs.cpp.

◆ vpNurbs() [2/2]

vpNurbs::vpNurbs ( const vpNurbs nurbs)

Copy constructor.

Definition at line 54 of file vpNurbs.cpp.

Member Function Documentation

◆ computeBasisFuns() [1/2]

vpBasisFunction * vpBSpline::computeBasisFuns ( double  l_u,
unsigned int  l_i,
unsigned int  l_p,
const std::vector< double > &  l_knots 
)
staticinherited

Compute the nonvanishing basis functions at $ l_u $ which is in the $ l_i $ th knot interval. All the basis functions are stored in an array such as :

N = $ N_{l_i,0}(l_u) $, $ N_{l_i-1,1}(l_u) $, $ N_{l_i,1}(l_u) $, ... , $ N_{l_i-k,k}(l_u) $, ..., $ N_{l_i,k}(l_u) $, ... , $ N_{l_i-p,p}(l_u) $, ... , $ N_{l_i,p}(l_u) $

Parameters
l_u: A real number which is between the extremities of the knot vector
l_i: the number of the knot interval in which $ l_u $ lies
l_p: Degree of the B-Spline basis functions.
l_knots: The knot vector
Returns
An array containing the nonvanishing basis functions at $ l_u $. The size of the array is $ l_p +1 $.
Examples
BSpline.cpp, and testNurbs.cpp.

Definition at line 143 of file vpBSpline.cpp.

Referenced by vpBSpline::computeBasisFuns(), vpBSpline::computeCurvePoint(), computeCurvePoint(), globalCurveApprox(), and globalCurveInterp().

◆ computeBasisFuns() [2/2]

vpBasisFunction * vpBSpline::computeBasisFuns ( double  u) const
inherited

Compute the nonvanishing basis functions at $ u $. All the basis functions are stored in an array such as :

N = $ N_{i,0}(u) $, $ N_{i-1,1}(u) $, $ N_{i,1}(u) $, ... , $ N_{i-k,k}(u) $, ..., $ N_{i,k}(u) $, ... , $ N_{i-p,p}(u) $, ... , $ N_{i,p}(u) $

where i the number of the knot interval in which $ u $ lies.

Parameters
u: A real number which is between the extremities of the knot vector
Returns
An array containing the nonvanishing basis functions at $ u $. The size of the array is $ p +1 $.

Definition at line 194 of file vpBSpline.cpp.

References vpBSpline::computeBasisFuns(), and vpBSpline::findSpan().

◆ computeCurveDers() [1/4]

vpImagePoint * vpBSpline::computeCurveDers ( double  l_u,
unsigned int  l_i,
unsigned int  l_p,
unsigned int  l_der,
const std::vector< double > &  l_knots,
const std::vector< vpImagePoint > &  l_controlPoints 
)
staticinherited

Compute the kth derivatives of $ C(u) $ for $ k = 0, ... , l_{der} $.

The formula used is the following :

\[ C^{(k)}(u) = \sum_{i=0}^n (N_{i,p}^{(k)}(u)P_i) \]

where $ i $ is the knot interval number in which $ u $ lies and $ p $ is the degree of the B-Spline basis function.

Parameters
l_u: A real number which is between the extremities of the knot vector
l_i: the number of the knot interval in which $ l_u $ lies
l_p: Degree of the B-Spline basis functions.
l_der: The last derivative to be computed.
l_knots: The knot vector
l_controlPoints: the list of control points.
Returns
an array of size l_der+1 containing the coordinates $ C^{(k)}(u) $ for $ k = 0, ... , l_der $. The kth derivative is in the kth cell of the array.

Definition at line 446 of file vpBSpline.cpp.

References vpBSpline::computeDersBasisFuns(), vpImagePoint::set_i(), vpImagePoint::set_ij(), and vpImagePoint::set_j().

◆ computeCurveDers() [2/4]

vpMatrix vpNurbs::computeCurveDers ( double  l_u,
unsigned int  l_i,
unsigned int  l_p,
unsigned int  l_der,
std::vector< double > &  l_knots,
std::vector< vpImagePoint > &  l_controlPoints,
std::vector< double > &  l_weights 
)
staticprotected

This function is used in the computeCurveDersPoint method.

Compute the kth derivatives of $ C(u) $ for $ k = 0, ... , l_{der} $.

The formula used is the following :

\[ C^{(k)}(u) = \sum_{i=0}^n (N_{i,p}^{(k)}(u)Pw_i) \]

where $ i $ is the knot interval number in which $ u $ lies, $ p $ is the degree of the NURBS basis function and $ Pw_i = (P_i w_i) $ contains the control points and the associated weights.

Parameters
l_u: A real number which is between the extremities of the knot vector.
l_i: the number of the knot interval in which $ l_u $ lies.
l_p: Degree of the NURBS basis functions.
l_der: The last derivative to be computed.
l_knots: The knot vector.
l_controlPoints: the list of control points.
l_weights: the list of weights.
Returns
a matrix of size (l_der+1)x3 containing the coordinates $ C^{(k)}(u) $ for $ k = 0, ... , l_{der} $. The kth derivative is in the kth line of the matrix. For each lines the first and the second column corresponds to the coordinates (i,j) of the point and the third column corresponds to the associated weight.

Definition at line 105 of file vpNurbs.cpp.

References vpBSpline::computeDersBasisFuns().

Referenced by computeCurveDersPoint().

◆ computeCurveDers() [3/4]

vpMatrix vpNurbs::computeCurveDers ( double  u,
unsigned int  der 
)
protected

This function is used in the computeCurveDersPoint method.

Compute the kth derivatives of $ C(u) $ for $ k = 0, ... , der $.

The formula used is the following :

\[ C^{(k)}(u) = \sum_{i=0}^n (N_{i,p}^{(k)}(u)Pw_i) \]

where $ i $ is the knot interval number in which $ u $ lies, $ p $ is the degree of the NURBS basis function and $ Pw_i = (P_i w_i) $ contains the control points and the associated weights.

Parameters
u: A real number which is between the extremities of the knot vector
der: The last derivative to be computed.
Returns
a matrix of size (l_der+1)x3 containing the coordinates $ C^{(k)}(u) $ for $ k = 0, ... , der $. The kth derivative is in the kth line of the matrix. For each lines the first and the second column corresponds to the coordinates (i,j) of the point and the third column corresponds to the associated weight.

Definition at line 133 of file vpNurbs.cpp.

References vpBSpline::computeDersBasisFuns(), and weights.

◆ computeCurveDers() [4/4]

vpImagePoint * vpBSpline::computeCurveDers ( double  u,
unsigned int  der 
) const
inherited

Compute the kth derivatives of $ C(u) $ for $ k = 0, ... , der $.

The formula used is the following :

\[ C^{(k)}(u) = \sum_{i=0}^n (N_{i,p}^{(k)}(u)P_i) \]

where $ i $ is the knot interval number in which $ u $ lies and $ p $ is the degree of the B-Spline basis function.

Parameters
u: A real number which is between the extremities of the knot vector
der: The last derivative to be computed.
Returns
an array of size der+1 containing the coordinates $ C^{(k)}(u) $ for $ k = 0, ... , der $. The kth derivative is in the kth cell of the array.

Definition at line 493 of file vpBSpline.cpp.

References vpBSpline::computeDersBasisFuns(), vpImagePoint::set_i(), vpImagePoint::set_ij(), and vpImagePoint::set_j().

◆ computeCurveDersPoint() [1/2]

vpImagePoint * vpNurbs::computeCurveDersPoint ( double  l_u,
unsigned int  l_i,
unsigned int  l_p,
unsigned int  l_der,
std::vector< double > &  l_knots,
std::vector< vpImagePoint > &  l_controlPoints,
std::vector< double > &  l_weights 
)
static

Compute the kth derivatives of $ C(u) $ for $ k = 0, ... , l_{der} $.

To see how the derivatives are computed refers to the Nurbs book.

Parameters
l_u: A real number which is between the extremities of the knot vector.
l_i: the number of the knot interval in which $ l_u $ lies.
l_p: Degree of the NURBS basis functions.
l_der: The last derivative to be computed.
l_knots: The knot vector.
l_controlPoints: the list of control points.
l_weights: the list of weights.
Returns
an array of size l_der+1 containing the coordinates $ C^{(k)}(u) $ for $ k = 0, ... , l_{der} $. The kth derivative is in the kth cell of the array.

Definition at line 156 of file vpNurbs.cpp.

References vpMath::comb(), computeCurveDers(), vpImagePoint::get_i(), vpImagePoint::get_j(), vpImagePoint::set_i(), vpImagePoint::set_ij(), and vpImagePoint::set_j().

Referenced by computeCurveDersPoint(), vpMeNurbs::localReSample(), vpMeNurbs::sample(), vpMeNurbs::seekExtremities(), vpMeNurbs::seekExtremitiesCanny(), and vpMeNurbs::updateDelta().

◆ computeCurveDersPoint() [2/2]

vpImagePoint * vpNurbs::computeCurveDersPoint ( double  u,
unsigned int  der 
)

Compute the kth derivatives of $ C(u) $ for $ k = 0, ... , l_{der} $.

To see how the derivatives are computed refers to the Nurbs book.

Parameters
u: A real number which is between the extremities of the knot vector
der: The last derivative to be computed.
Returns
an array of size l_der+1 containing the coordinates $ C^{(k)}(u) $ for $ k = 0, ... , der $. The kth derivative is in the kth cell of the array.

Definition at line 187 of file vpNurbs.cpp.

References computeCurveDersPoint(), vpBSpline::findSpan(), and weights.

◆ computeCurvePoint() [1/4]

vpImagePoint vpBSpline::computeCurvePoint ( double  l_u,
unsigned int  l_i,
unsigned int  l_p,
const std::vector< double > &  l_knots,
const std::vector< vpImagePoint > &  l_controlPoints 
)
staticinherited

Compute the coordinates of a point $ C(u) = \sum_{i=0}^n (N_{i,p}(u)P_i) $ corresponding to the knot $ u $.

Parameters
l_u: A real number which is between the extremities of the knot vector
l_i: the number of the knot interval in which $ l_u $ lies
l_p: Degree of the B-Spline basis functions.
l_knots: The knot vector
l_controlPoints: the list of control points.

return the coordinates of a point corresponding to the knot $ u $.

Examples
BSpline.cpp.

Definition at line 376 of file vpBSpline.cpp.

References vpBSpline::computeBasisFuns(), vpImagePoint::set_i(), and vpImagePoint::set_j().

◆ computeCurvePoint() [2/4]

vpImagePoint vpNurbs::computeCurvePoint ( double  l_u,
unsigned int  l_i,
unsigned int  l_p,
std::vector< double > &  l_knots,
std::vector< vpImagePoint > &  l_controlPoints,
std::vector< double > &  l_weights 
)
static

Compute the coordinates of a point $ C(u) = \frac{\sum_{i=0}^n (N_{i,p}(u)w_iP_i)}{\sum_{i=0}^n (N_{i,p}(u)w_i)} $ corresponding to the knot $ u $.

Parameters
l_u: A real number which is between the extremities of the knot vector.
l_i: the number of the knot interval in which $ l_u $ lies.
l_p: Degree of the NURBS basis functions.
l_knots: The knot vector.
l_controlPoints: the list of control points.
l_weights: the list of weights.
Returns
The coordinates of a point corresponding to the knot $ u $.
Examples
testNurbs.cpp.

Definition at line 56 of file vpNurbs.cpp.

References vpBSpline::computeBasisFuns(), vpImagePoint::set_i(), and vpImagePoint::set_j().

Referenced by vpMeNurbs::display(), vpMeNurbs::localReSample(), vpMeNurbs::seekExtremitiesCanny(), vpMeNurbs::track(), and vpMeNurbs::updateDelta().

◆ computeCurvePoint() [3/4]

vpImagePoint vpNurbs::computeCurvePoint ( double  u)

Compute the coordinates of a point $ C(u) = \frac{\sum_{i=0}^n (N_{i,p}(u)w_iP_i)}{\sum_{i=0}^n (N_{i,p}(u)w_i)} $ corresponding to the knot $ u $.

Parameters
u: A real number which is between the extremities of the knot vector

return the coordinates of a point corresponding to the knot $ u $.

Definition at line 81 of file vpNurbs.cpp.

References vpBSpline::computeBasisFuns(), vpImagePoint::set_i(), vpImagePoint::set_j(), and weights.

◆ computeCurvePoint() [4/4]

vpImagePoint vpBSpline::computeCurvePoint ( double  u) const
inherited

Compute the coordinates of a point $ C(u) = \sum_{i=0}^n (N_{i,p}(u)P_i) $ corresponding to the knot $ u $.

Parameters
u: A real number which is between the extremities of the knot vector

return the coordinates of a point corresponding to the knot $ u $.

Definition at line 405 of file vpBSpline.cpp.

References vpBSpline::computeBasisFuns(), vpImagePoint::set_i(), and vpImagePoint::set_j().

◆ computeDersBasisFuns() [1/2]

vpBasisFunction ** vpBSpline::computeDersBasisFuns ( double  l_u,
unsigned int  l_i,
unsigned int  l_p,
unsigned int  l_der,
const std::vector< double > &  l_knots 
)
staticinherited

Compute the nonzero basis functions and their derivatives until the $ l_der $ th derivative. All the functions are computed at l_u.

Warning
$ l_der $ must be under or equal $ l_p $.

The result is given as an array of size l_der+1 x l_p+1. The kth line corresponds to the kth basis functions derivatives.

The formula to compute the kth derivative at $ u $ is :

\[ N_{i,p}^{(k)}(u) =p \left( \frac{N_{i,p-1}^{(k-1)}}{u_{i+p}-u_i} - \frac{N_{i+1,p-1}^{(k-1)}}{u_{i+p+1}-u_{i+1}} \right) \]

where $ i $ is the knot interval number in which $ u $ lies and $ p $ is the degree of the B-Spline basis function.

Parameters
l_u: A real number which is between the extremities of the knot vector
l_i: the number of the knot interval in which $ l_u $ lies
l_p: Degree of the B-Spline basis functions.
l_der: The last derivative to be computed.
l_knots: The knot vector
Returns
the basis functions and their derivatives as an array of size l_der+1 x l_p+1. The kth line corresponds to the kth basis functions derivatives.

Example : return[0] is the list of the 0th derivatives ie the basis functions. return[k] is the list of the kth derivatives.

Examples
BSpline.cpp, and testNurbs.cpp.

Definition at line 229 of file vpBSpline.cpp.

Referenced by vpBSpline::computeCurveDers(), computeCurveDers(), and vpBSpline::computeDersBasisFuns().

◆ computeDersBasisFuns() [2/2]

vpBasisFunction ** vpBSpline::computeDersBasisFuns ( double  u,
unsigned int  der 
) const
inherited

Compute the nonzero basis functions and their derivatives until the $ der $ th derivative. All the functions are computed at u.

Warning
$ der $ must be under or equal $ p $.

The result is given as an array of size der+1 x p+1. The kth line corresponds to the kth basis functions derivatives.

The formula to compute the kth derivative at $ u $ is :

\[ N_{i,p}^{(k)}(u) =p \left( \frac{N_{i,p-1}^{(k-1)}}{u_{i+p}-u_i} - \frac{N_{i+1,p-1}^{(k-1)}}{u_{i+p+1}-u_{i+1}} \right) \]

where $ i $ is the knot interval number in which $ u $ lies and $ p $ is the degree of the B-Spline basis function.

Parameters
u: A real number which is between the extremities of the knot vector
der: The last derivative to be computed.
Returns
the basis functions and their derivatives as an array of size der+1 x p+1. The kth line corresponds to the kth basis functions derivatives.

Example : return[0] is the list of the 0th derivatives ie the basis functions. return[k] is the list of the kth derivatives.

Definition at line 359 of file vpBSpline.cpp.

References vpBSpline::computeDersBasisFuns(), and vpBSpline::findSpan().

◆ curveKnotIns() [1/2]

void vpNurbs::curveKnotIns ( double  l_u,
unsigned int  l_k,
unsigned int  l_s,
unsigned int  l_r,
unsigned int  l_p,
std::vector< double > &  l_knots,
std::vector< vpImagePoint > &  l_controlPoints,
std::vector< double > &  l_weights 
)
static

Insert $ l_r $ times a knot in the $ l_k $ th interval of the knot vector. The inserted knot $ l_u $ has multiplicity $ l_s $.

Of course the knot vector changes. But The list of control points and the list of the associated weights change too.

Parameters
l_u: A real number which is between the extremities of the knot vector and which has to be inserted.
l_k: The number of the knot interval in which $ l_u $ lies.
l_s: Multiplicity of $ l_u $
l_r: Number of times $ l_u $ has to be inserted.
l_p: Degree of the NURBS basis functions.
l_knots: The knot vector
l_controlPoints: the list of control points.
l_weights: the list of weights.

Definition at line 194 of file vpNurbs.cpp.

References vpMatrix::insert(), and vpImagePoint::set_ij().

Referenced by curveKnotIns().

◆ curveKnotIns() [2/2]

void vpNurbs::curveKnotIns ( double  u,
unsigned int  s = 0,
unsigned int  r = 1 
)

Insert $ r $ times a knot in the $ k $ th interval of the knot vector. The inserted knot $ u $ has multiplicity $ s $.

Of course the knot vector changes. But The list of control points and the list of the associated weights change too.

Parameters
u: A real number which is between the extremities of the knot vector and which has to be inserted.
s: Multiplicity of $ l_u $.
r: Number of times $ l_u $ has to be inserted.

Definition at line 246 of file vpNurbs.cpp.

References curveKnotIns(), vpBSpline::findSpan(), and weights.

◆ findSpan() [1/2]

unsigned int vpBSpline::findSpan ( double  l_u,
unsigned int  l_p,
const std::vector< double > &  l_knots 
)
staticinherited

Find the knot interval in which the parameter $ l_u $ lies. Indeed $ l_u \in [u_i, u_{i+1}[ $

Example : The knot vector is the following $ U = \{0, 0 , 1 , 2 ,3 , 3\} $ with $ p $ is equal to 1.

  • For $ l_u $ equal to 0.5 the method will return 1.
  • For $ l_u $ equal to 2.5 the method will return 3.
  • For $ l_u $ equal to 3 the method will return 3.
Parameters
l_u: The knot whose knot interval is seeked.
l_p: Degree of the B-Spline basis functions.
l_knots: The knot vector
Returns
the number of the knot interval in which $ l_u $ lies.
Examples
BSpline.cpp, and testNurbs.cpp.

Definition at line 80 of file vpBSpline.cpp.

References vpMath::maximum(), and vpMath::round().

Referenced by vpBSpline::computeBasisFuns(), computeCurveDersPoint(), vpBSpline::computeDersBasisFuns(), curveKnotIns(), vpBSpline::findSpan(), globalCurveApprox(), globalCurveInterp(), and refineKnotVectCurve().

◆ findSpan() [2/2]

unsigned int vpBSpline::findSpan ( double  u) const
inherited

Find the knot interval in which the parameter $ u $ lies. Indeed $ u \in [u_i, u_{i+1}[ $

Example : The knot vector is the following $ U = \{0, 0 , 1 , 2 ,3 , 3\} $ with $ p $ is equal to 1.

  • For $ u $ equal to 0.5 the method will return 1.
  • For $ u $ equal to 2.5 the method will return 3.
  • For $ u $ equal to 3 the method will return 3.
Parameters
u: The knot whose knot interval is seeked.
Returns
the number of the knot interval in which $ u $ lies.

Definition at line 124 of file vpBSpline.cpp.

References vpBSpline::findSpan().

◆ get_controlPoints()

void vpBSpline::get_controlPoints ( std::list< vpImagePoint > &  list) const
inlineinherited

Gets all the control points.

Parameters
list: A std::list containing the coordinates of the control points.
Examples
BSpline.cpp, and testNurbs.cpp.

Definition at line 137 of file vpBSpline.h.

◆ get_crossingPoints()

void vpBSpline::get_crossingPoints ( std::list< vpImagePoint > &  list) const
inlineinherited

Gets all the crossing points (used in the interpolation method)

Parameters
list: A std::list containing the coordinates of the crossing points.

Definition at line 164 of file vpBSpline.h.

◆ get_knots()

void vpBSpline::get_knots ( std::list< double > &  list) const
inlineinherited

Gets all the knots.

Parameters
list: A std::list containing the value of the knots.
Examples
BSpline.cpp, and testNurbs.cpp.

Definition at line 150 of file vpBSpline.h.

◆ get_p()

unsigned int vpBSpline::get_p ( ) const
inlineinherited

Gets the degree of the B-Spline.

Returns
the degree of the B-Spline.
Examples
BSpline.cpp, and testNurbs.cpp.

Definition at line 129 of file vpBSpline.h.

◆ get_weights()

void vpNurbs::get_weights ( std::list< double > &  list) const
inline

Gets all the weights relative to the control points.

Parameters
list[out] : A std::list containing weights relative to the control points.
Examples
testNurbs.cpp.

Definition at line 178 of file vpNurbs.h.

◆ globalCurveApprox() [1/5]

void vpNurbs::globalCurveApprox ( const std::list< vpImagePoint > &  l_crossingPoints,
unsigned int  n 
)

Method which enables to compute a NURBS curve approximating a set of data points.

The data points are approximated thanks to a least square method.

The result of the method is composed by a knot vector, a set of control points and a set of associated weights.

Parameters
l_crossingPoints: The list of data points which have to be interpolated.
n: The desired number of control points. The parameter n must be under or equal to the number of data points.

Definition at line 728 of file vpNurbs.cpp.

References globalCurveApprox(), and weights.

◆ globalCurveApprox() [2/5]

void vpNurbs::globalCurveApprox ( const std::list< vpMeSite > &  l_crossingPoints,
unsigned int  n 
)

Method which enables to compute a NURBS curve approximating a set of data points.

The data points are approximated thanks to a least square method.

The result of the method is composed by a knot vector, a set of control points and a set of associated weights.

Parameters
l_crossingPoints: The list of data points which have to be interpolated.
n: The desired number of control points. This parameter n must be under or equal to the number of data points.

Definition at line 737 of file vpNurbs.cpp.

References globalCurveApprox(), and weights.

◆ globalCurveApprox() [3/5]

void vpNurbs::globalCurveApprox ( std::vector< vpImagePoint > &  l_crossingPoints,
unsigned int  l_p,
unsigned int  l_n,
std::vector< double > &  l_knots,
std::vector< vpImagePoint > &  l_controlPoints,
std::vector< double > &  l_weights 
)
static

Method which enables to compute a NURBS curve approximating a set of data points.

The data points are approximated thanks to a least square method.

The result of the method is composed by a knot vector, a set of control points and a set of associated weights.

Parameters
l_crossingPoints: The list of data points which have to be interpolated.
l_p: Degree of the NURBS basis functions.
l_n: The desired number of control points. l_n must be under or equal to the number of data points.
l_knots: The knot vector.
l_controlPoints: the list of control points.
l_weights: the list of weights.
Examples
testNurbs.cpp.

Definition at line 595 of file vpNurbs.cpp.

References vpMatrix::AtA(), vpBSpline::computeBasisFuns(), vpBSpline::findSpan(), vpMatrix::pseudoInverse(), and vpImagePoint::set_ij().

Referenced by globalCurveApprox(), and vpMeNurbs::track().

◆ globalCurveApprox() [4/5]

void vpNurbs::globalCurveApprox ( unsigned int  n)

Method which enables to compute a NURBS curve approximating a set of data points.

The data points are approximated thanks to a least square method.

The result of the method is composed by a knot vector, a set of control points and a set of associated weights.

Definition at line 747 of file vpNurbs.cpp.

References globalCurveApprox(), and weights.

◆ globalCurveApprox() [5/5]

void vpNurbs::globalCurveApprox ( vpList< vpMeSite > &  l_crossingPoints,
unsigned int  n 
)

Method which enables to compute a NURBS curve approximating a set of data points.

The data points are approximated thanks to a least square method.

The result of the method is composed by a knot vector, a set of control points and a set of associated weights.

Parameters
l_crossingPoints: The list of data points which have to be interpolated.
n: The desired number of control points. This parameter n must be under or equal to the number of data points.

Definition at line 714 of file vpNurbs.cpp.

References vpList< type >::front(), vpMeSite::get_ifloat(), vpMeSite::get_jfloat(), globalCurveApprox(), vpList< type >::next(), vpList< type >::outside(), vpList< type >::value(), and weights.

◆ globalCurveInterp() [1/5]

void vpNurbs::globalCurveInterp ( )

Method which enables to compute a NURBS curve passing through a set of data points.

The result of the method is composed by a knot vector, a set of control points and a set of associated weights.

Definition at line 593 of file vpNurbs.cpp.

References weights.

Referenced by globalCurveInterp().

◆ globalCurveInterp() [2/5]

void vpNurbs::globalCurveInterp ( const std::list< vpImagePoint > &  l_crossingPoints)

Method which enables to compute a NURBS curve passing through a set of data points.

The result of the method is composed by a knot vector, a set of control points and a set of associated weights.

Parameters
l_crossingPoints: The list of data points which have to be interpolated.

Definition at line 564 of file vpNurbs.cpp.

References globalCurveInterp(), and weights.

◆ globalCurveInterp() [3/5]

void vpNurbs::globalCurveInterp ( const std::list< vpMeSite > &  l_crossingPoints)

Method which enables to compute a NURBS curve passing through a set of data points.

The result of the method is composed by a knot vector, a set of control points and a set of associated weights.

Parameters
l_crossingPoints: The list of data points which have to be interpolated.

Definition at line 574 of file vpNurbs.cpp.

References vpImagePoint::distance(), vpMeSite::get_ifloat(), vpMeSite::get_jfloat(), globalCurveInterp(), and weights.

◆ globalCurveInterp() [4/5]

void vpNurbs::globalCurveInterp ( std::vector< vpImagePoint > &  l_crossingPoints,
unsigned int  l_p,
std::vector< double > &  l_knots,
std::vector< vpImagePoint > &  l_controlPoints,
std::vector< double > &  l_weights 
)
static

Method which enables to compute a NURBS curve passing through a set of data points.

The result of the method is composed by a knot vector, a set of control points and a set of associated weights.

Parameters
l_crossingPoints: The list of data points which have to be interpolated.
l_p: Degree of the NURBS basis functions. This value need to be > 0.
l_knots: The knot vector.
l_controlPoints: The list of control points.
l_weights: the list of weights.
Examples
testNurbs.cpp.

Definition at line 466 of file vpNurbs.cpp.

References vpException::badValue, vpBSpline::computeBasisFuns(), vpBSpline::findSpan(), vpMatrix::pseudoInverse(), and vpImagePoint::set_ij().

Referenced by vpMeNurbs::initTracking().

◆ globalCurveInterp() [5/5]

void vpNurbs::globalCurveInterp ( vpList< vpMeSite > &  l_crossingPoints)

Method which enables to compute a NURBS curve passing through a set of data points.

The result of the method is composed by a knot vector, a set of control points and a set of associated weights.

Parameters
l_crossingPoints: The list of data points which have to be interpolated.

Definition at line 543 of file vpNurbs.cpp.

References vpImagePoint::distance(), vpList< type >::front(), vpMeSite::get_ifloat(), vpMeSite::get_jfloat(), globalCurveInterp(), vpList< type >::next(), vpList< type >::outside(), vpImagePoint::set_ij(), vpList< type >::value(), and weights.

◆ refineKnotVectCurve() [1/2]

void vpNurbs::refineKnotVectCurve ( double *  l_x,
unsigned int  l_r,
unsigned int  l_p,
std::vector< double > &  l_knots,
std::vector< vpImagePoint > &  l_controlPoints,
std::vector< double > &  l_weights 
)
static

Insert $ l_r $ knots in the knot vector.

Of course the knot vector changes. But The list of control points and the list of the associated weights change too.

Parameters
l_x: Several real numbers which are between the extremities of the knot vector and which have to be inserted.
l_r: Number of knot in the array $ l_x $.
l_p: Degree of the NURBS basis functions.
l_knots: The knot vector
l_controlPoints: the list of control points.
l_weights: the list of weights.

Definition at line 253 of file vpNurbs.cpp.

References vpBSpline::findSpan(), and vpImagePoint::set_i().

Referenced by refineKnotVectCurve().

◆ refineKnotVectCurve() [2/2]

void vpNurbs::refineKnotVectCurve ( double *  x,
unsigned int  r 
)

Insert $ r $ knots in the knot vector.

Of course the knot vector changes. But The list of control points and the list of the associated weights change too.

Parameters
x: Several real numbers which are between the extremities of the knot vector and which have to be inserted.
r: Number of knot in the array $ l_x $.

Definition at line 333 of file vpNurbs.cpp.

References refineKnotVectCurve(), and weights.

◆ removeCurveKnot() [1/2]

unsigned int vpNurbs::removeCurveKnot ( double  l_u,
unsigned int  l_r,
unsigned int  l_num,
double  l_TOL 
)

Remove $ num $ times the knot $ u $ from the knot vector. The removed knot $ u $ is the $ r $ th vector in the knot vector.

Of course the knot vector changes. But The list of control points and the list of the associated weights change too.

Parameters
l_u: A real number which is between the extremities of the knot vector and which has to be removed.
l_r: Index of $ l_u $ in the knot vector.
l_num: Number of times $ l_u $ has to be removed.
l_TOL: A parameter which has to be computed.
Returns
The number of time that l_u was removed.

$ TOL = \frac{dw_{min}}{1+|P|_{max}} $

where $ w_{min} $ is the minimal weight on the original curve, $ |P|_{max} $ is the maximum distance of any point on the original curve from the origin and $ d $ is the desired bound on deviation.

Definition at line 461 of file vpNurbs.cpp.

References removeCurveKnot(), and weights.

◆ removeCurveKnot() [2/2]

unsigned int vpNurbs::removeCurveKnot ( double  l_u,
unsigned int  l_r,
unsigned int  l_num,
double  l_TOL,
unsigned int  l_s,
unsigned int  l_p,
std::vector< double > &  l_knots,
std::vector< vpImagePoint > &  l_controlPoints,
std::vector< double > &  l_weights 
)
static

Remove $ l_num $ times the knot $ l_u $ from the knot vector. The removed knot $ l_u $ is the $ l_r $ th vector in the knot vector.

Of course the knot vector changes. But The list of control points and the list of the associated weights change too.

Parameters
l_u: A real number which is between the extremities of the knot vector and which has to be removed.
l_r: Index of $ l_u $ in the knot vector.
l_num: Number of times $ l_u $ has to be removed.
l_TOL: A parameter which has to be computed.
l_s: Multiplicity of $ l_u $.
l_p: Degree of the NURBS basis functions.
l_knots: The knot vector
l_controlPoints: the list of control points.
l_weights: the list of weights.
Returns
The number of time that l_u was removed.

$ l_{TOL} = \frac{dw_{min}}{1+|P|_{max}} $

where $ w_{min} $ is the minimal weight on the original curve, $ |P|_{max} $ is the maximum distance of any point on the original curve from the origin and $ d $ is the desired bound on deviation.

Definition at line 338 of file vpNurbs.cpp.

References vpImagePoint::get_i(), vpImagePoint::get_j(), vpImagePoint::set_i(), vpImagePoint::set_j(), and vpMath::sqr().

Referenced by removeCurveKnot().

◆ set_controlPoints()

void vpBSpline::set_controlPoints ( const std::list< vpImagePoint > &  list)
inlineinherited

Sets all the control points.

Parameters
list: A std::list containing the coordinates of the control points
Examples
BSpline.cpp, and testNurbs.cpp.

Definition at line 184 of file vpBSpline.h.

◆ set_crossingPoints()

void vpBSpline::set_crossingPoints ( const std::list< vpImagePoint > &  list)
inlineinherited

Sets all the crossing points (used in the interpolation method)

Parameters
list: A std::list containing the coordinates of the crossing points

Definition at line 211 of file vpBSpline.h.

◆ set_knots()

void vpBSpline::set_knots ( const std::list< double > &  list)
inlineinherited

Sets all the knots.

Parameters
list: A std::list containing the value of the knots.
Examples
BSpline.cpp, and testNurbs.cpp.

Definition at line 197 of file vpBSpline.h.

◆ set_p()

void vpBSpline::set_p ( unsigned int  degree)
inlineinherited

Sets the degree of the B-Spline.

Parameters
degree: the degree of the B-Spline.
Examples
BSpline.cpp, and testNurbs.cpp.

Definition at line 177 of file vpBSpline.h.

◆ set_weights()

void vpNurbs::set_weights ( const std::list< double > &  list)
inline

Sets all the knots.

Parameters
list: A std::list containing the value of the knots.
Examples
testNurbs.cpp.

Definition at line 190 of file vpNurbs.h.

Member Data Documentation

◆ weights

std::vector<double> vpNurbs::weights
protected

Vector which contains the weights associated to each control Points.

Definition at line 96 of file vpNurbs.h.

Referenced by computeCurveDers(), computeCurveDersPoint(), computeCurvePoint(), curveKnotIns(), globalCurveApprox(), globalCurveInterp(), refineKnotVectCurve(), and removeCurveKnot().