The package comprises of a graphical utility to place uniform B-spline control points and see how the B-spline is redrawn as control points or control point weights are adjusted, and functions to estimate B-splines with known knot vector, given a set of noisy data points either with known or unknown associated parameter values.
As regards the interactive interface, the user is shown a figure window with axes in which to choose control points of a uniform B-spline. As points are placed in the axes, the B-spline of specified order is drawn progressively. The user may terminate adding control points by pressing ENTER or ESC, or may place the last control point with a right mouse button click.
Once done, control points may be adjusted with drag-and-drop. Hold down the left mouse button over any control point and drag it to another location. Control point adjustment works in 3D; use the rotation tool to set a different camera position. It is also possible to explicitly set the x, y and z coordinates as well as the weight of a control point: click on the point, enter new values and hit ENTER.
As regards the non-interactive interface, functions include calculating and drawing basis functions, computing points of a (weighted or unweighted) B-spline curve with de Boor's algorithm, and estimating B-spline control points given noisy data, either with or without parameter values associated with the observed data points.
From a programmers' perspective, this example illustrates how to use nested functions to extend variable scope, implement drag-and-drop operations, combine normalized and pixel units for control docking and register multiple callbacks for a single event in an interactive user interface.
USAGE
The simplest way to get started is to run "bspline_gui", which activates the figure window to place B-spline control points interactively. Examples are bundled to illustrate various B-spline curve computation and approximation methods.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
it is not working in matlab2019b
Great work! I have one suggestion. As I am concerned about fast computation to evaluate bspline_deboor(), I suggest using
[~,I] = histc(U,t)
instead of
I = bspline_deboor_interval(U,t)
in line 46. Seems to be much faster (of the order of a magnitude).
All the best
do this programmes give the b-spline piecewise functions?
do this codes recorrect the drawing?
Is it possible to use this package to fit periodic b-splines to a closed set of points (i.e. a polygon)?
In order to work on newer versions of Matlab (still with a few errors) comment the lines 45-65 (editx, edity, ...)
Error using gui_bind_event (line 17)
Expected input to be one of these types:
numeric
Instead its type was matlab.ui.Figure.
Error in uispanedit (line 30)
gui_bind_event(fig, 'ResizeFcn', {@uispanedit_resize, editbox, height});
Error in bspline_gui (line 45)
editx = uispanedit(panel, ...
its really good and helping. can any one tell if this package could be used to find control points of a particular interval or segment by providing a curve x,y point.
what i mean is that if i generate a b-spline curve, now i randomly select any x,y pair on curve data values, and i want to know form which control point segment this data point belongs?
(Not Matlab 2016b compatible)
Error using gui_bind_event (line 17)
Expected input to be one of these types:
numeric
Instead its type was matlab.ui.Figure.
I'm receiving this error :(
Expected input to be one of these types:
numeric
Instead its type was matlab.ui.Figure.
Hi, thanks for the excellent code.
I have a question about the value where the B-spline is to be evalued. can i evalue the B-spline for x = 0:0.1:3; as in the exemple for the basis functions where x = 0:0.1:3;?
helpful and interesting, thanks!
Hi, thank you for this! I have a question. I'm quite new to bsplines and matlab and I was wondering if there's anything out there in the matlab world that lets me measure the length of a cubic bspline generated in matlab from say this bspline package?
Great work!
I found a bug in bspline_basis.m. The last line in
function y = bspline_basis_recurrence(j,n,t,x)
should be:
else
y(:) = t(j+1) <= x & x < t(j+2);
end
There should not be an equal in the second term x<t(j+2). If you plot the basis function using knot vector [0 1 2 3 4 5 6] and order 3, you will see the error.
Great code. I am pretty new with working with B-splines and am wondering if there is a way you would reccomend (with your code) to find the derivative of a given spline with a given set of control points?
Scratch last comment, got the control points to work...
Excellent code! 5 stars...
Only thing I can't seem to get to work is altering the control point locations post-zooming or rotating of the plot (the control points seem to change to non-interactive graph points after using any tools on the figure or camera toolbars) -- any suggestions?
Agree with Evgeny Pr with the problem. Otherwise it's good!
Hello!
Thank you for good job!
I found one error in the function "bspline_wdeboor". The problem in if statement (if nargin > 5).
Must be:
if (nargin < 5)
[Y,u] = bspline_deboor(n,t,P);
else
[Y,u] = bspline_deboor(n,t,P,u);
end
The same approximation is unstable. Strongly depends on the knots vector.