bSplines.c
// Recursive computation of B-spline functions.

Recursive computation of B-spline functions.
Recursive computation of B - spline functions .
float Bspline(int i, int m, float u)
{
	float coef1, coef2;
	if ( m == 1 )
	{
		if ( ( knots[i] < u ) && ( u <= knots[i+1] ) ) return 1.0;
		else return 0.0;
	}
	else
	{
		if ( knots[i+m-1] == knots[i] ) coef1 = 0;
		else coef1 = (u - knots[i])/(knots[i+m-1] - knots[i]);
		if ( knots[i+m] == knots[i+1] ) coef2 = 0;
		else coef2 = (knots[i+m] - u)/(knots[i+m] - knots[i+1]);
		return ( coef1 * Bspline(i, m-1, u) + coef2 * Bspline(i+1 ,m-1 ,u) );
	}
}
float Bspline ( int i , int m , float u ) { float coef1 , coef2 ; if ( m == 1 ) { if ( ( knots [ i ] < u ) && ( u <= knots [ i + 1 ] ) ) return 1.0 ; else return 0.0 ; } else { if ( knots [ i + m - 1 ] == knots [ i ] ) coef1 = 0 ; else coef1 = ( u - knots [ i ] ) / ( knots [ i + m - 1 ] - knots [ i ] ) ; if ( knots [ i + m ] == knots [ i + 1 ] ) coef2 = 0 ; else coef2 = ( knots [ i + m ] - u ) / ( knots [ i + m ] - knots [ i + 1 ] ) ; return ( coef1 * Bspline ( i , m - 1 , u ) + coef2 * Bspline ( i + 1 , m - 1 , u ) ) ; } }
Recursive computation of B-spline functions.
Recursive computation of B - spline functions .