BSpline

class BSpline(*args, **kwargs)

Bases: pybind11_object

Class that provides tools to compute and manipulate a 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 \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.

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) = \sum_{i=0}^n (N_{i,p}(u)P_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.core.BSpline) -> None

Basic constructor.

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

  1. __init__(self: visp._visp.core.BSpline, bspline: visp._visp.core.BSpline) -> None

Copy constructor.

Methods

__init__

Overloaded function.

computeCurvePoint

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

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.

findSpanFromSpline

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

get_controlPoints

Gets all the control points.

get_crossingPoints

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

get_knots

Gets all the knots.

get_p

Gets the degree of the B-Spline.

set_controlPoints

Sets all the control points.

set_crossingPoints

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

set_knots

Sets all the knots.

set_p

Sets the degree of the B-Spline.

Inherited Methods

Operators

__doc__

__init__

Overloaded function.

__module__

Attributes

__annotations__

controlPoints

crossingPoints

knots

p

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: visp._visp.core.BSpline) -> None

Basic constructor.

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

  1. __init__(self: visp._visp.core.BSpline, bspline: visp._visp.core.BSpline) -> None

Copy constructor.

computeCurvePoint(self, u: float) 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:
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.

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.

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.