Create B-Spline curve using MATLAB

  • Context: MATLAB 
  • Thread starter Thread starter Praba89
  • Start date Start date
  • Tags Tags
    Curve Matlab
Click For Summary
SUMMARY

This discussion focuses on creating a B-spline curve using MATLAB, specifically addressing the calculation of second-degree B-spline basis functions. The user seeks guidance on transitioning from first-degree to second-degree basis functions, utilizing the recursive B-spline basis formula. Key MATLAB functions provided include bcurve_eval, findKnotSpan, and getBasisFuncs, which facilitate B-spline curve evaluation with a specified knot vector and control points.

PREREQUISITES
  • Understanding of B-spline basis functions, particularly zeroth and first degree
  • Familiarity with MATLAB programming environment
  • Knowledge of curve interpolation techniques
  • Basic understanding of recursive algorithms
NEXT STEPS
  • Research "MATLAB B-spline curve fitting" for practical applications
  • Explore "B-spline basis function derivation" for deeper theoretical insights
  • Learn about "MATLAB control point manipulation" for advanced curve design
  • Investigate "knot vector optimization" techniques to enhance B-spline performance
USEFUL FOR

This discussion is beneficial for students, researchers, and professionals involved in computer graphics, geometric modeling, and numerical analysis, particularly those working on projects related to curve interpolation and B-spline implementations in MATLAB.

Praba89
Messages
1
Reaction score
0
I need a MATLAB expert to guide me on how to create a b-spline curve using MATLAB Software. I understand the B-spline basis function calculations for zeroth and first degree but I have no idea on how to calculate for the 2nd degree. I need a favor on that part. I am currently working on my final year project titled INTERPOLATION OF PLANAR CURVE WITH DIFFERENT PARAMETERISATION. Thanks in Advance.
 
Last edited:
Physics news on Phys.org
Just like you linearly interpolate the 0th degree basis functions to get the 1st degree basis functions, you have to linearly interpolate the 1st degree basis functions to get the 2nd degree. The recursive B-spline basis formula tells you how to do that.

Here's some code snippets for MATLAB does B-spline curve evaluation for a degree-p B-spline curve with knot vector U at parameter value u with control point array C:

Code:
function S = bcurve_eval(u,p,U,C)
    uspan = findKnotSpan(u,p,U);
    Nu = getBasisFuncs(u,p,U,uspan);
    
    S = zeros(1,numel(C(1,:)));
    for i=0:p
        index = uspan-p+i;
        S = S + C(index+1,:) * Nu(i+1);
    end
end

Code:
function i = findKnotSpan(u,p,U)
    k = numel(U)-1;
    n = k-p-1;
    if u == U(n+1 +1)
        i = n;
        return
    end
    l = p +1;
    h = n+1 +1;
    i = floor((l+h)/2);
    while u < U(i) || u >= U(i+1)
        if u < U(i)
            h = i;
        else
            l = i;
        end;
        i = floor((l+h)/2);
    end
    i = i-1;
end

Code:
function N = getBasisFuncs(u,p,U,i)
    left = zeros(1,p+1);
    right = zeros(1,p+1);
    N = zeros(1,p+1);
    N(1) = 1;
    for j=1:p
        left(j+1) = u - U(i+1-j +1);
        right(j+1) = U(i+j +1) - u;
        s = 0;
        for r=0:j-1
            temp = N(r +1) / (right(r+1 + 1) + left(j-r +1));
            N(r +1) = s + right(r+1 +1) * temp;
            s = left(j-r +1) * temp;
        end
        N(j +1) = s;
    end
end

Hope that helps. Let me know if you have questions.
 
  • Like
Likes   Reactions: Yaaqob Saad and (deleted member)

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K