(degree, knot_vector, span, knot, order)
return ders
Computes the derivative of one basis functions for a single parameter.

    Implementation of Algorithm A2.5 from The NURBS Book by Piegl & Tiller.

    :param degree: degree, :math:`p`
    :type degree: int
    :param knot_vector: knot_vector, :math:`U`
    :type knot_vector: list, tuple
    :param span: knot span, :math:`i`
    :type span: int
    :param knot: knot or parameter, :math:`u`
    :type knot: float
    :param order: order of the derivative
    :type order: int
    :return: basis function derivatives
    :rtype: list
Computes the derivative of one basis functions for a single parameter.
Computes the derivative of one basis functions for a single parameter .
def basis_function_ders_one(degree, knot_vector, span, knot, order):
    """ Computes the derivative of one basis functions for a single parameter.

    Implementation of Algorithm A2.5 from The NURBS Book by Piegl & Tiller.

    :param degree: degree, :math:`p`
    :type degree: int
    :param knot_vector: knot_vector, :math:`U`
    :type knot_vector: list, tuple
    :param span: knot span, :math:`i`
    :type span: int
    :param knot: knot or parameter, :math:`u`
    :type knot: float
    :param order: order of the derivative
    :type order: int
    :return: basis function derivatives
    :rtype: list
    """
    ders = [0.0 for _ in range(0, order + 1)]

    # Knot is outside of span range
    if (knot < knot_vector[span]) or (knot >= knot_vector[span + degree + 1]):
        for k in range(0, order + 1):
            ders[k] = 0.0

        return ders

    N = [[0.0 for _ in range(0, degree + 1)] for _ in range(0, degree + 1)]

    # Initializing the zeroth degree basis functions
    for j in range(0, degree + 1):
        if knot_vector[span + j] <= knot < knot_vector[span + j + 1]:
            N[j][0] = 1.0

    # Computing all basis functions values for all degrees inside the span
    for k in range(1, degree + 1):
        saved = 0.0
        # Detecting zeros saves computations
        if N[0][k - 1] != 0.0:
            saved = ((knot - knot_vector[span]) * N[0][k - 1]) / (knot_vector[span + k] - knot_vector[span])

        for j in range(0, degree - k + 1):
            Uleft = knot_vector[span + j + 1]
            Uright = knot_vector[span + j + k + 1]

            # Zero detection
            if N[j + 1][k - 1] == 0.0:
                N[j][k] = saved
                saved = 0.0
            else:
                temp = N[j + 1][k - 1] / (Uright - Uleft)
                N[j][k] = saved + (Uright - knot) * temp
                saved = (knot - Uleft) * temp

    # The basis function value is the zeroth derivative
    ders[0] = N[0][degree]

    # Computing the basis functions derivatives
    for k in range(1, order + 1):
        # Buffer for computing the kth derivative
        ND = [0.0 for _ in range(0, k + 1)]

        # Basis functions values used for the derivative
        for j in range(0, k + 1):
            ND[j] = N[j][degree - k]

        # Computing derivatives used for the kth basis function derivative

        # Derivative order for the k-th basis function derivative
        for jj in range(1, k + 1):
            if ND[0] == 0.0:
                saved = 0.0
            else:
                saved = ND[0] / (knot_vector[span + degree - k + jj] - knot_vector[span])

            # Index of the Basis function derivatives
            for j in range(0, k - jj + 1):
                Uleft = knot_vector[span + j + 1]
                # Wrong in The NURBS Book: -k is missing.
                # The right expression is the same as for saved with the added j offset
                Uright = knot_vector[span + j + degree - k + jj + 1]

                if ND[j + 1] == 0.0:
                    ND[j] = (degree - k + jj) * saved
                    saved = 0.0
                else:
                    temp = ND[j + 1] / (Uright - Uleft)

                    ND[j] = (degree - k + jj) * (saved - temp)
                    saved = temp

        ders[k] = ND[0]

    return ders
def basis_function_ders_one ( degree , knot_vector , span , knot , order ) : ders = [ 0.0 for _ in range ( 0 , order + 1 ) ] # Knot is outside of span range if ( knot < knot_vector [ span ] ) or ( knot >= knot_vector [ span + degree + 1 ] ) : for k in range ( 0 , order + 1 ) : ders [ k ] = 0.0 return ders N = [ [ 0.0 for _ in range ( 0 , degree + 1 ) ] for _ in range ( 0 , degree + 1 ) ] # Initializing the zeroth degree basis functions for j in range ( 0 , degree + 1 ) : if knot_vector [ span + j ] <= knot < knot_vector [ span + j + 1 ] : N [ j ] [ 0 ] = 1.0 # Computing all basis functions values for all degrees inside the span for k in range ( 1 , degree + 1 ) : saved = 0.0 # Detecting zeros saves computations if N [ 0 ] [ k - 1 ] != 0.0 : saved = ( ( knot - knot_vector [ span ] ) * N [ 0 ] [ k - 1 ] ) / ( knot_vector [ span + k ] - knot_vector [ span ] ) for j in range ( 0 , degree - k + 1 ) : Uleft = knot_vector [ span + j + 1 ] Uright = knot_vector [ span + j + k + 1 ] # Zero detection if N [ j + 1 ] [ k - 1 ] == 0.0 : N [ j ] [ k ] = saved saved = 0.0 else : temp = N [ j + 1 ] [ k - 1 ] / ( Uright - Uleft ) N [ j ] [ k ] = saved + ( Uright - knot ) * temp saved = ( knot - Uleft ) * temp # The basis function value is the zeroth derivative ders [ 0 ] = N [ 0 ] [ degree ] # Computing the basis functions derivatives for k in range ( 1 , order + 1 ) : # Buffer for computing the kth derivative ND = [ 0.0 for _ in range ( 0 , k + 1 ) ] # Basis functions values used for the derivative for j in range ( 0 , k + 1 ) : ND [ j ] = N [ j ] [ degree - k ] # Computing derivatives used for the kth basis function derivative # Derivative order for the k-th basis function derivative for jj in range ( 1 , k + 1 ) : if ND [ 0 ] == 0.0 : saved = 0.0 else : saved = ND [ 0 ] / ( knot_vector [ span + degree - k + jj ] - knot_vector [ span ] ) # Index of the Basis function derivatives for j in range ( 0 , k - jj + 1 ) : Uleft = knot_vector [ span + j + 1 ] # Wrong in The NURBS Book: -k is missing. # The right expression is the same as for saved with the added j offset Uright = knot_vector [ span + j + degree - k + jj + 1 ] if ND [ j + 1 ] == 0.0 : ND [ j ] = ( degree - k + jj ) * saved saved = 0.0 else : temp = ND [ j + 1 ] / ( Uright - Uleft ) ND [ j ] = ( degree - k + jj ) * ( saved - temp ) saved = temp ders [ k ] = ND [ 0 ] return ders