Nurbs

class Nurbs(*args, **kwargs)

Bases: BSpline

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 :

    \[\begin{split}N_{i,0}(u) = \left\{\begin{array}{cc} 1 & \mbox{if } u_i \leq u_{i+1} \\0 & else \end{array}\right.\end{split}\]
    \[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.

Overloaded function.

  1. __init__(self: visp._visp.me.Nurbs) -> None

Basic constructor.

The degree \(p\) of the NURBS basis functions is set to 3 to compute cubic NURBS.

  1. __init__(self: visp._visp.me.Nurbs, nurbs: visp._visp.me.Nurbs) -> None

Copy constructor.

Methods

__init__

Overloaded function.

computeCurvePoint

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\) .

computeCurvePointStatic

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\) .

curveKnotIns

Insert \(r\) times a knot in the \(k\) th interval of the knot vector.

curveKnotInsStatic

Insert \(l_r\) times a knot in the \(l_k\) th interval of the knot vector.

get_weights

Gets all the weights relative to the control points.

globalCurveApprox

Overloaded function.

globalCurveApproxStatic

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

globalCurveInterp

Overloaded function.

globalCurveInterpStatic

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

removeCurveKnot

Remove \(num\) times the knot \(u\) from the knot vector.

removeCurveKnotStatic

Remove \(l_num\) times the knot \(l_u\) from the knot vector.

set_weights

Sets all the knots.

Inherited Methods

get_p

Gets the degree of the B-Spline.

computeCurvePointFromSpline

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

findSpan

Find the knot interval in which the parameter \(u\) lies.

set_controlPoints

Sets all the control points.

get_controlPoints

Gets all the control points.

set_knots

Sets all the knots.

crossingPoints

p

get_knots

Gets all the knots.

knots

set_p

Sets the degree of the B-Spline.

controlPoints

get_crossingPoints

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

findSpanFromSpline

Find the knot interval in which the parameter \(l_u\) lies.

set_crossingPoints

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

Operators

__doc__

__init__

Overloaded function.

__module__

Attributes

__annotations__

controlPoints

crossingPoints

knots

p

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: visp._visp.me.Nurbs) -> None

Basic constructor.

The degree \(p\) of the NURBS basis functions is set to 3 to compute cubic NURBS.

  1. __init__(self: visp._visp.me.Nurbs, nurbs: visp._visp.me.Nurbs) -> None

Copy constructor.

computeCurvePoint(self, u: float) visp._visp.core.ImagePoint

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\) .

return the coordinates of a point corresponding to the knot \(u\) .

Parameters:
u: float

A real number which is between the extremities of the knot vector

static computeCurvePointFromSpline(l_u: float, l_i: int, l_p: int, l_knots: list[float], l_controlPoints: list[visp._visp.core.ImagePoint]) visp._visp.core.ImagePoint

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

return the coordinates of a point corresponding to the knot \(u\) .

Parameters:
l_u: float

A real number which is between the extremities of the knot vector

l_i: int

the number of the knot interval in which \(l_u\) lies

l_p: int

Degree of the B-Spline basis functions.

l_knots: list[float]

The knot vector

l_controlPoints: list[visp._visp.core.ImagePoint]

the list of control points.

static computeCurvePointStatic(l_u: float, l_i: int, l_p: int, l_knots: list[float], l_controlPoints: list[visp._visp.core.ImagePoint], l_weights: list[float]) tuple[visp._visp.core.ImagePoint, list[float], list[visp._visp.core.ImagePoint], list[float]]

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: float

A real number which is between the extremities of the knot vector.

l_i: int

the number of the knot interval in which \(l_u\) lies.

l_p: int

Degree of the NURBS basis functions.

l_knots: list[float]

The knot vector.

l_controlPoints: list[visp._visp.core.ImagePoint]

the list of control points.

l_weights: list[float]

the list of weights.

Returns:

A tuple containing:

  • The coordinates of a point corresponding to the knot \(u\) .

  • l_knots: The knot vector.

  • l_controlPoints: the list of control points.

  • l_weights: the list of weights.

curveKnotIns(self, u: float, s: int = 0, r: int = 1) None

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: float

A real number which is between the extremities of the knot vector and which has to be inserted.

s: int = 0

Multiplicity of \(l_u\) .

r: int = 1

Number of times \(l_u\) has to be inserted.

static curveKnotInsStatic(l_u: float, l_k: int, l_s: int, l_r: int, l_p: int, l_knots: list[float], l_controlPoints: list[visp._visp.core.ImagePoint], l_weights: list[float]) tuple[list[float], list[visp._visp.core.ImagePoint], list[float]]

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: float

A real number which is between the extremities of the knot vector and which has to be inserted.

l_k: int

The number of the knot interval in which \(l_u\) lies.

l_s: int

Multiplicity of \(l_u\)

l_r: int

Number of times \(l_u\) has to be inserted.

l_p: int

Degree of the NURBS basis functions.

l_knots: list[float]

The knot vector

l_controlPoints: list[visp._visp.core.ImagePoint]

the list of control points.

l_weights: list[float]

the list of weights.

Returns:

A tuple containing:

  • l_knots: The knot vector

  • l_controlPoints: the list of control points.

  • l_weights: the list of weights.

findSpan(self, u: float) int

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: float

The knot whose knot interval is seeked.

Returns:

the number of the knot interval in which \(u\) lies.

static findSpanFromSpline(l_u: float, l_p: int, l_knots: list[float]) int

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: float

The knot whose knot interval is seeked.

l_p: int

Degree of the B-Spline basis functions.

l_knots: list[float]

The knot vector

Returns:

the number of the knot interval in which \(l_u\) lies.

get_controlPoints(self) list[visp._visp.core.ImagePoint]

Gets all the control points.

Returns:

A tuple containing:

  • list: A std::list containing the coordinates of the control points.

get_crossingPoints(self) list[visp._visp.core.ImagePoint]

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

Returns:

A tuple containing:

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

get_knots(self) list[float]

Gets all the knots.

Returns:

A tuple containing:

  • list: A std::list containing the value of the knots.

get_p(self) int

Gets the degree of the B-Spline.

Returns:

the degree of the B-Spline.

get_weights(self, list: list[float]) list[float]

Gets all the weights relative to the control points.

Parameters:
list: list[float]

[out] : A std::list containing weights relative to the control points.

Returns:

A tuple containing:

  • list: [out] : A std::list containing weights relative to the control points.

globalCurveApprox(*args, **kwargs)

Overloaded function.

  1. globalCurveApprox(self: visp._visp.me.Nurbs, l_crossingPoints: vpList<vpMeSite>, n: int) -> None

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.

  1. globalCurveApprox(self: visp._visp.me.Nurbs, l_crossingPoints: list[visp._visp.core.ImagePoint], n: int) -> None

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.

  1. globalCurveApprox(self: visp._visp.me.Nurbs, l_crossingPoints: list[visp._visp.me.MeSite], n: int) -> None

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.

  1. globalCurveApprox(self: visp._visp.me.Nurbs, n: int) -> None

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.

static globalCurveApproxStatic(l_crossingPoints: list[visp._visp.core.ImagePoint], l_p: int, l_n: int, l_knots: list[float], l_controlPoints: list[visp._visp.core.ImagePoint], l_weights: list[float]) tuple[list[visp._visp.core.ImagePoint], list[float], list[visp._visp.core.ImagePoint], list[float]]

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: list[visp._visp.core.ImagePoint]

The list of data points which have to be interpolated.

l_p: int

Degree of the NURBS basis functions.

l_n: int

The desired number of control points. l_n must be under or equal to the number of data points.

l_knots: list[float]

The knot vector.

l_controlPoints: list[visp._visp.core.ImagePoint]

the list of control points.

l_weights: list[float]

the list of weights.

Returns:

A tuple containing:

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

  • l_knots: The knot vector.

  • l_controlPoints: the list of control points.

  • l_weights: the list of weights.

globalCurveInterp(*args, **kwargs)

Overloaded function.

  1. globalCurveInterp(self: visp._visp.me.Nurbs, l_crossingPoints: vpList<vpMeSite>) -> None

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.

  1. globalCurveInterp(self: visp._visp.me.Nurbs, l_crossingPoints: list[visp._visp.core.ImagePoint]) -> None

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.

  1. globalCurveInterp(self: visp._visp.me.Nurbs, l_crossingPoints: list[visp._visp.me.MeSite]) -> None

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.

  1. globalCurveInterp(self: visp._visp.me.Nurbs) -> None

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.

static globalCurveInterpStatic(l_crossingPoints: list[visp._visp.core.ImagePoint], l_p: int, l_knots: list[float], l_controlPoints: list[visp._visp.core.ImagePoint], l_weights: list[float]) tuple[list[visp._visp.core.ImagePoint], list[float], list[visp._visp.core.ImagePoint], list[float]]

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: list[visp._visp.core.ImagePoint]

The list of data points which have to be interpolated.

l_p: int

Degree of the NURBS basis functions. This value need to be > 0.

l_knots: list[float]

The knot vector.

l_controlPoints: list[visp._visp.core.ImagePoint]

The list of control points.

l_weights: list[float]

the list of weights.

Returns:

A tuple containing:

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

  • l_knots: The knot vector.

  • l_controlPoints: The list of control points.

  • l_weights: the list of weights.

removeCurveKnot(self, l_u: float, l_r: int, l_num: int, l_TOL: float) int

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.

\(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.

Parameters:
l_u: float

A real number which is between the extremities of the knot vector and which has to be removed.

l_r: int

Index of \(l_u\) in the knot vector.

l_num: int

Number of times \(l_u\) has to be removed.

l_TOL: float

A parameter which has to be computed.

Returns:

The number of time that l_u was removed.

static removeCurveKnotStatic(l_u: float, l_r: int, l_num: int, l_TOL: float, l_s: int, l_p: int, l_knots: list[float], l_controlPoints: list[visp._visp.core.ImagePoint], l_weights: list[float]) tuple[int, list[float], list[visp._visp.core.ImagePoint], list[float]]

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.

\(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.

Parameters:
l_u: float

A real number which is between the extremities of the knot vector and which has to be removed.

l_r: int

Index of \(l_u\) in the knot vector.

l_num: int

Number of times \(l_u\) has to be removed.

l_TOL: float

A parameter which has to be computed.

l_s: int

Multiplicity of \(l_u\) .

l_p: int

Degree of the NURBS basis functions.

l_knots: list[float]

The knot vector

l_controlPoints: list[visp._visp.core.ImagePoint]

the list of control points.

l_weights: list[float]

the list of weights.

Returns:

A tuple containing:

  • The number of time that l_u was removed.

  • l_knots: The knot vector

  • l_controlPoints: the list of control points.

  • l_weights: the list of weights.

set_controlPoints(self, list: list[visp._visp.core.ImagePoint]) None

Sets all the control points.

Parameters:
list: list[visp._visp.core.ImagePoint]

A std::list containing the coordinates of the control points

set_crossingPoints(self, list: list[visp._visp.core.ImagePoint]) None

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

Parameters:
list: list[visp._visp.core.ImagePoint]

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

set_knots(self, list: list[float]) None

Sets all the knots.

Parameters:
list: list[float]

A std::list containing the value of the knots.

set_p(self, degree: int) None

Sets the degree of the B-Spline.

Parameters:
degree: int

the degree of the B-Spline.

set_weights(self, list: list[float]) None

Sets all the knots.

Parameters:
list: list[float]

A std::list containing the value of the knots.