[Python] B-Spline derivative using de Boor's algorithm

Discussão em 'Python' iniciado por Stack, Fevereiro 11, 2025.

  1. Stack

    Stack Membro Participativo

    Wikipedia gives us a Python implementation for the de Boor's algorithm:

    def deBoor(k, x, t, c, p):
    """
    Evaluates S(x).

    Args
    ----
    k: index of knot interval that contains x
    x: position
    t: array of knot positions, needs to be padded as described above
    c: array of control points
    p: degree of B-spline
    """
    d = [c[j + k - p] for j in range(0, p+1)]

    for r in range(1, p+1):
    for j in range(p, r-1, -1):
    alpha = (x - t[j+k-p]) / (t[j+1+k-r] - t[j+k-p])
    d[j] = (1.0 - alpha) * d[j-1] + alpha * d[j]

    return d[p]


    Is there a similar algorithm calculating the derivative of the B-Spline interpolated curve (or even n-th derivative)?

    I know that mathematically it is reduced to using a spline of the lower order but can't apply it to the de Boor's algorithm.

    Continue reading...

Compartilhe esta Página