No BSD License
Highlights from
NURBS
-
basisfun(i,u,p,U) ...
BASISFUN Basis function for B-Spline
-
bspdegelev(d,c,k,t)
BSPDEGELEV Degree elevate a univariate B-Spline.
-
bspderiv(d,c,k)
BSPDERIV B-Spline derivative
-
bspeval(d,c,k,u)
BSPEVAL Evaluate B-Spline at parametric points
-
bspkntins(d,c,k,u)
BSPKNTINS Insert knots into a B-Spline
-
findspan(n,p,u,U) ...
FINDSPAN Find the span of a B-Spline knot vector at a parametric point
-
View all files
from
NURBS
by Daniel Claxton
Converted NURBS toolbox
|
| findspan(n,p,u,U)
|
function s = findspan(n,p,u,U)
% FINDSPAN Find the span of a B-Spline knot vector at a parametric point
% -------------------------------------------------------------------------
% ADAPTATION of FINDSPAN from C
% -------------------------------------------------------------------------
%
% Calling Sequence:
%
% s = findspan(n,p,u,U)
%
% INPUT:
%
% n - number of control points - 1
% p - spline degree
% u - parametric point
% U - knot sequence
%
% RETURN:
%
% s - knot span
%
% Algorithm A2.1 from 'The NURBS BOOK' pg68
% int findspan(int n, int p, double u, double *U) {
% int low, high, mid;
% // special case
if (u==U(n+2)), s=n; return, end % if (u == U[n+1]) return(n);
%
% // do binary search
low = p; % low = p;
high = n + 1; % high = n + 1;
mid = floor((low + high) / 2); % mid = (low + high) / 2;
while (u < U(mid+1) || u >= U(mid+2)) % while (u < U[mid] || u >= U[mid+1]) {
if (u < U(mid+1)) % if (u < U[mid])
high = mid; % high = mid;
else % else
low = mid; % low = mid;
end
mid = floor((low + high) / 2); % mid = (low + high) / 2;
end % }
%
s = mid; % return(mid);
% }
|
|
Contact us at files@mathworks.com