Splines.BSpline — Type
BSpline(degree, knots, ctrlpts)

Construct a B-Spline object

Arguments

  • deg::Integer: degree
  • knots::Vector{Float64}:: a knot vector (u0, ... un+1)
  • ctrlpts::Vector{Vector{Float64}}:: control points. outer index is number of control points, inner index of dimensionality of point.
source
Splines.NURBS — Type
NURBS(degree, knots, weights, ctrlpts)

Construct a NURBS object

Arguments

  • deg::Integer: degree
  • knots::Vector{Float64}:: a knot vector (u0, ... un+1)
  • weights::Vector{Float64}:: a corresponding vector of weights
  • ctrlpts::Vector{Vector{Float64}}:: control points. outer index is number of control points, inner index of dimensionality of point.
source
Splines.bernsteincoeff — Method
bernsteincoeff(u, n, i)

Calculate Bernstein Coefficient (Bezier Basis Function) defined as:

\[B_{i, n}(u) = \binom{n}{i} u^i (1-u)^{n-1}\]

at parametric point, $u$, where $0\leq u\leq1$. $u$ may either be a single value or an array.

(see NURBS, eqn 1.8)

source
Splines.binomialcoeff — Method
binomialcoeff(n, i)

Calculate the Binomial Coefficient defined as:

\[\binom{n}{i} = \frac{n!}{i!(n-1)!}\]

source
Splines.curvederivativecontrolpoints — Method
curvederivativecontrolpoints(n, p, U, P, d, r1, r2)

Compute control points of curve derivatives:

\[\mathbf{C}^{(k)}(u) = \sum_{i=0}^{n-k}N_{i,p-k}(u) \mathbf{P}_i^{(k)}\]

with

\[\mathbf{P}_i^{(k)} = \begin{cases} \mathbf{P}_i & k=0 \\ \frac{p-k+1}{u_{i+p+1}-u_{i+k}}\left(\mathbf{P}_{i+1}^{(k)} - \mathbf{P}_i^{(k)} \right) & k > 0 \end{cases}\]

(see NURBS, eqn 3.8 and A3.3)

Arguments

  • bspline::BSpline: bspline object
  • `r1::Integer : first control point index to take derivatives at
  • `r2::Integer : last control point index to take derivatives at
  • d::Float: derivative order (0 ≤ k ≦ d)

Returns

  • PK::Matrix{Vector{Float}}: PK[i, j] is the ith derivative of the jth control point
source
Splines.curvederivatives — Method
curvederivatives(bspline, u, d)

Compute a curve point and its derivatives up do the dth derivative at parametric point, $u$. (NURBS, A3.2)

Arguments

  • bspline::BSpline: bspline object
  • u::Float: point on spline to evaluate at
  • d::Float: derivative order (0 ≤ k ≤ d)

Returns

  • CK::Vector{Vector{Float}}. where CK[0] is the point, CK[1] the first derivative, and so on.
source
Splines.curvederivatives — Method
curvederivatives(nurbs, u, d)

Compute a curve point and its derivatives up do the dth derivative at parametric point, $u$. (NURBS, A3.2)

Arguments

  • nurbs::NURBS: bspline object
  • u::Float: point on spline to evaluate at
  • d::Float: derivative order (0 ≤ k ≤ d)

Returns

  • CK::Vector{Vector{Float}} where CK[1] is the point, CK[2] the first derivative, and so on.
source
Splines.curveknotinsertion — Method
curveknotinsertion(np, p, UP, Pw, u, k, s, r)

Compute a new curve from knot insertion. Using the formula:

\[\mathbf{Q}_{i, r}^w = \alpha_{i, r} \mathbf{Q}_{i, r-1}^w + (1-\alpha_{i, r}) \mathbf{Q}_{i-1, r-1}^w\]

where

\[\alpha_{i, r} = \begin{cases} 1 & i \leq k-p+r-1 \\ \frac{\bar{u} - u_i}{u_{i+p-r+1} - \bar{u}_i} & k-p+r \leq i\leq k-s \\ 0 & i \geq k-s+1 \end{cases}\]

(see NURBS eqn 5.15 and A5.1)

Inputs:

  • np : the number of control points minus 1 (the index of the last control point) before insertion
  • p : the curve order
  • UP : the knot vector before insertion
  • Pw : the set of weighted control points and weights before insertion
  • u : the knot to be added
  • k : the span index at which the knot is to be inserted.
  • s : numer of instances of the new knot alrady present in the knot vector, UP
  • r : number of times the new knot is inserted (it is assumed that $r+s \leq p$ )

Outputs:

  • nq : the number of control points minus 1 (the index of the last control point) after insertion
  • UQ : the knot vector after insertion
  • Qw : the set of weighted control points and weights after insertion
source
Splines.curvepoint — Method

Evaluate point on B-spline curve (NURBS, A3.1)

Arguments

  • bspline::BSpline: bspline object
  • u::Float: point on spline to evaluate at

Returns

  • C::Vector{Float}: point in ND space
source
Splines.curvepoint — Method

Evaluate point on rational b-spline curve (NURBS, A4.1)

Arguments

  • nurbs::NURBS: NURBS object
  • u::Float: point on spline to evaluate at

Returns

  • C::Vector{Float}: point in ND space
source
Splines.decasteljau_bezier1D — Method
decasteljau_bezier1D(P, u)

Calculate a point along a Bezier curve at the parametric point, $u_0$, based on the control points, $\mathbf{P}$, using deCasteljau's Algorithm:

\[\mathbf{P}_{k, i}(u_0) = (1- u_0)\mathbf{P}_{k-1, i}(u_0) + u_0 \mathbf{P}_{k-1, i+1}(u_0)\]

for $k = 1, ..., n$ and $i = 0, ..., n-k$, where $u_0$ is any single value from 0 to 1.

(see NURBS, eqn 1.12 and A1.5)

source
Splines.degreeelevatecurve — Method
degreeelevatecurve(n,p,U,Pw,t)

Raise degree of spline from p to p $+t$, $t \geq 1$ by computing the new control point vector and knot vector.

Knots are inserted to divide the spline into equivalent Bezier Curves. These curves are then degree elevated using the following equation.

\[\mathbf{P}^t_i = \sum^{\textrm{min}(p,i)}_{j=\textrm{max}(0,i-t)} \frac{\binom{p}{j} \binom{t}{i-j} \mathbf{P}_j}{\binom{p+t}{i}}~,~~~~~i=0,...,p+t\]

where $\mathbf{P}^t_i$ are the degree elevated control points after $t$ -degree elevations

Finally, the excess knots are removed and the degree elevated spline is returned.

(see NURBS eqn 5.36, A5.9)

Inputs:

  • n : the number of control points minus 1 (the index of the last control point) before degree elevation
  • p : the curve order
  • U : the knot vector before degree elevation
  • Pw : the set of weighted control points and weights before degree elevation
  • t : the number of degrees to elevate, i.e. the new curve degree is p+t

Outputs:

  • nh : the number of control points minus 1 (the index of the last control point) after degree elevation
  • Uh : the knot vector after degree elevation
  • Qw : the set of weighted control points and weights after degree elevation
source
Splines.getspanindex — Method
getspanindex(deg, knots, u)

(private function) binary search to find span index of vector, knots, in which the parametric point, u, lies. (NURBS A2.1)

Arguments

  • deg::Integer: degree
  • knots::Vector{Float64}:: a knot vector (u0, ... un+1)
  • u::Float64`: nondimensional location we are searching for

Returns

  • span::Integer: corresponding index i for u between knotsi and knotsi+1
source
Splines.globalcurveinterpolation — Method
globalcurveinterpolation(pts, deg)

Interpolate ctrl points pts, with a B-Spline of degree deg. (NURBS A9.1)

Arguments

  • pts::Vector{Vector{Float}}: outer vector of length npts, inner vector of length dimension of space
  • deg::Integer: degree of B-spline

Outputs:

  • bspline::BSpline: bspline object
source
Splines.leastsquarescurve — Method
leastsquarescurve(pts, nctrl, deg)

Least squares fit to provided points. (NURBS section 9.4.1) TODO: Currently hard-coded to 2D data.

Arguments

  • pts::Vector{Vector{Float}}: data points
  • nctrl::Integer: number of control points to use in fit
  • deg::Integer: degree of bspline used in fit

Returns

  • bspline::BSpline: a BSpline object
source
Splines.nurbsbasis — Method
nurbsbasis(u,p,d,U,w)

Get rational basis functions and derivatives.

\[R_{i,p}(u) = \frac{N_{i,p}(u)w_i}{\sum_{j=0}^n N_{j,p}(u)w_j}\]

where $N_{i,p}(u )$ are B-Spline Basis Functions and $w_i$ are weights associated with the NURBS control points.

(see NURBS eqn 4.2)

Inputs:

  • u : parametric point of interest
  • p : the curve order
  • d : the max derivative order (n ≦ p)
  • U : the knot vector
  • w : control point weights
source
Splines.refineknotvectorcurve — Method
refineknotvectorcurve(n, p, U, Pw, X, r)

Refine curve knot vector using NURBS A5.4.

This algorithm is simply a knot insertion algorithm that allows for multiple knots to be added simulataneously, i.e., a knot refinement procedure.

Inputs:

  • n : the number of control points minus 1 (the index of the last control point) before insertion
  • p : the curve order
  • U : the knot vector before insertion
  • Pw : the set of weighted control points and weights before insertion
  • X : elements, in ascending order, to be inserted into U (elements should be repeated according to their multiplicities, e.g., if x and y have multiplicites 2 and 3, X = [x,x,y,y,y])
  • r : length of X vector - 1

Outputs:

  • Ubar : the knot vector after insertion
  • Qw : the set of weighted control points and weights after insertion
source
Splines.simple_bezier1D — Method
simple_bezier1D(P, u)

Calculate a point along a Bezier curve at the parametric point, $u$, based on the control points, $\mathbf{P}$, where the Bezier curve, $\mathbf{C}(u)$, is defined as:

\[\mathbf{C}(u) = \sum_{i=0}^n B_{i, n}(u) \mathbf{P}_i~, ~~~~ 0 \leq u \leq 1\]

where $B$ is the basis (Bernstein Coefficient) at parametric point, $u$, as calculated from bernsteincoeff, and n is the number of control points in vector $\mathbf{P}$. Again, $u$ may either be a single value or an array.

(see NURBS eqn 1.7)

source
Splines.singlebasisfunction — Method
singlebasisfunction(i, deg, knots, u)

(private function) Compute single basis function N_i^p. (NURBS A2.4)

Arguments

  • i::Integer : the index of the basis (the i in N_i)
  • deg::Integer : the basis degree up to the the curve order
  • knots::Vector{Float} : the knot vector
  • u::Float : parametric point of interest

Returns

  • Nip::Float: the N_i^p basis function value
source