Functions

OpenTissue::spline::detail Namespace Reference

Functions

template<typename knot_container >
knot_container::value_type compute_basis (int const &i, int const &k, typename knot_container::value_type const &u, knot_container const &U)
template<typename knot_container , typename matrix_type >
void compute_basis_derivatives (typename knot_container::value_type const &u, int J, int const &k, knot_container const &U, matrix_type &dQ)
template<typename knot_container >
int compute_knot_span (typename knot_container::value_type const &u, int const &k, knot_container const &U)
template<typename vector_type , typename knot_container >
void compute_nonzero_basis (typename knot_container::value_type const &u, int const k, knot_container const &U, vector_type &N)
template<typename knot_container , typename point_container >
void compute_point_on_spline (typename knot_container::value_type const &u, int const k, knot_container const &U, point_container const &P, typename point_container::value_type &p)
template<typename matrix_type , typename knot_container >
void initialize_m_table (int const &i, typename knot_container::value_type const &u, int const &k, knot_container const &U, matrix_type &M)
template<typename knot_container , typename point_container >
void insert_knot (typename knot_container::value_type const &u, int k, knot_container &U, point_container &P)
template<typename knot_container , typename point_container >
void compute_closed_periodic (int const k, knot_container &U, point_container &P)
template<typename vector_type , typename point_container >
void solve_tridiagonal (vector_type const &a, vector_type const &b, vector_type const &c, point_container &P, point_container const &X, int const n)

Function Documentation

template<typename knot_container >
knot_container::value_type OpenTissue::spline::detail::compute_basis ( int const &  i,
int const &  k,
typename knot_container::value_type const &  u,
knot_container const &  U 
) [inline]

The i'th Basis Blending Function. This method implements the de Cox's recursive definition of a B-spline basis function.

[If time permits implement optimized version NURBS page 74]

Parameters:
i The index of the basis function.
k The order of the spline (and not the degree, which are k-1).
u The parameter value at which the i'th basis function should be evaluated at.
T Knotvector.
Returns:
The value of the i'th k'th order basis function at the parameter value u.
template<typename knot_container , typename matrix_type >
void OpenTissue::spline::detail::compute_basis_derivatives ( typename knot_container::value_type const &  u,
int  J,
int const &  k,
knot_container const &  U,
matrix_type dQ 
) [inline]

Computation of derivatives of the basisfunctions. This method efficiently computes all derivatives from 0 upto J'th order of the basisfunctions at the parameter value u. Note that the 0'th order derivative is simply the basisfunctions themselves.

The method can for instance be used to retrieve velocity and acceleration information about an object moving along the spline.

Parameters:
u The parameter value at which the derivatives should be computed.
J The highest order derivative, which should be computed, should be less than the order of the spline since all other higher order derivatives is trivially known to be zero.
k Order of basisfunction.
U The knot-vector.
dQ dQ is a (J+1,k) matrix which upon return will contain the computed derivatives.
template<typename knot_container , typename point_container >
void OpenTissue::spline::detail::compute_closed_periodic ( int const   k,
knot_container U,
point_container P 
) [inline]

Convert the knot-vector and controlpoints to closed periodic. Afterwards they can be used to draw a closed B-spline curve. See pp 200 Applied Geometry for Computer Graphics and CAD 2nd Edition.

Parameters:
k Order.
U Knot-vector. Must contain n+2 knots. Will be updated to contain: (n+2*d+2) knots where d=k-1.
P A controlpoint container. Must contain n+1 controlpoints.
template<typename knot_container >
int OpenTissue::spline::detail::compute_knot_span ( typename knot_container::value_type const &  u,
int const &  k,
knot_container const &  U 
) [inline]

Find Knot Span Based on the algorithm in The NURBS Book pp 68.

U[j] <= u < U[j+1] (*)

The knot vector is defined to be

U = [ u0, u1, ..., u_{k-1}, u_k, u_{k+1}, ..., u_{n-1}, u_n, u_{n+1}, ..., u_{n+k} ]

Where

u_0 = u_1 = ... = u_{k-1} and u_{n+1} = u_{n+2} = ... = u_{n+k}

Parameters:
u The parameter value.
k The order of the spline (and knot the degree, which are k-1).
U A reference to the knot vector. It will have n+k+1 knot values.
Returns:
The index value of the lowest knot value in the knot span, which overlaps with u. In other words the value of j in the equation (*).
template<typename vector_type , typename knot_container >
void OpenTissue::spline::detail::compute_nonzero_basis ( typename knot_container::value_type const &  u,
int const   k,
knot_container const &  U,
vector_type N 
) [inline]

Compute nonzero basisfunctions. Uses a triangular scheme to compute only nonzero k k-order basisfunctions.

Disregarding the dynamic memory allocation in this method it is infact the optimal implementation. For details look at pp.68-70 in "The Nurbs Book" by L. Piegl and W. Tiller.

Parameters:
u Paramter value.
k Order of the basisfunction.
U Knotvector.
N A reference to a vector, which upon return will contain the values of the basisfunctions.
template<typename knot_container , typename point_container >
void OpenTissue::spline::detail::compute_point_on_spline ( typename knot_container::value_type const &  u,
int const   k,
knot_container const &  U,
point_container const &  P,
typename point_container::value_type &  p 
) [inline]

Get Point On Spline. Computes af point on a B-spline. Disregarding the dynamic memory allocation in this method it is infact the optimal implementation. For details look at pp.68-70 in "The Nurbs Book" by L. Piegl and W. Tiller.

Parameters:
u Parameter value.
k Order of basisfunction.
U Knot-vector.
P A controlpoint container.
p A reference to a vector, which upon return will contain the computed point on the spline.
template<typename matrix_type , typename knot_container >
void OpenTissue::spline::detail::initialize_m_table ( int const &  i,
typename knot_container::value_type const &  u,
int const &  k,
knot_container const &  U,
matrix_type M 
) [inline]

Initialize the M table used when computing the derivatives. The M table is a k*k matrix containing values for up to k k-order nonzero basisfunctions and their corresponding knot-differences.

Parameters:
i The index of the basis function.
u The parameter value at which the i'th basis function should be evaluated at.
k The order of the spline (and not the degree, which are k-1).
U A reference to the knotvector. It will have n+k+1 knot values.
M A reference to the M table that will be initialized when the function returns.
template<typename knot_container , typename point_container >
void OpenTissue::spline::detail::insert_knot ( typename knot_container::value_type const &  u,
int  k,
knot_container U,
point_container P 
) [inline]

Insert Knot. This implementation is based on the algorithm in "Fundamentals of Computer Aided Geometric Design", by J. Horschek and D. Lasser, pp. 190-192.

Note that the algorithm in the book does not treat the cases where

r < K or r > n-1

For an open spline this will cause interpolation of non-existent de Boor points and therefor cause array out bound exceptions!!! In short we must require the multiplicity at the endpoints to be K!!!

Parameters:
u The new knot-value that should be inserted.
k Order.
U Knot-container that upon return will contain the new knot u.
P Controlpoint container that upon return will contain the original and new de Boor points.
template<typename vector_type , typename point_container >
void OpenTissue::spline::detail::solve_tridiagonal ( vector_type const &  a,
vector_type const &  b,
vector_type const &  c,
point_container P,
point_container const &  X,
int const   n 
) [inline]

This method solves a tridiagonal linear equation set in m-dimensions.

M P = X

where M is a tridiagonal matrix defined as follows:

| b[0] c[1] | | a[1] b[1] c[2] | | a[2] .. | | b[n-2] c[n-2] | | a[n-2] b[n-1] |

Parameters:
a-c The explict basis functions from PBA pp 744.
P Upon return P will contains the determined controlpoints.
X The datapoints the cubic B-spline must run through.
n Index from the knot-vector. Called with n-1