[Python] splprep Invalid inputs

Discussão em 'Python' iniciado por Stack, Dezembro 9, 2024.

  1. Stack

    Stack Membro Participativo

    data sample:

    curves =
    [[[ 163.73873901 163.79016113 195.15170288]
    [ 163.75410461 163.74798584 195.00090027]
    [ 163.82121277 163.3908844 193.4805603 ]
    ...
    [ 136.28196716 134.58721924 5.28508425]
    [ 136.14976501 134.63981628 5.04161263]
    [ 135.96887207 134.7321167 4.71693945]],
    ...
    [[ 163.73873901 163.79016113 195.15170288]
    [ 163.75410461 163.74798584 195.00090027]
    [ 163.82121277 163.3908844 193.4805603 ]
    ...
    [ 129.41056824 143.86738586 101.12477112]
    [ 129.30464172 143.82444763 100.86767578]
    [ 128.98980713 143.91737366 100.56091309]]]


    The beginning of these curves overlap, and the points behind them are different. It's like a tree, all the curves go from the root to all the branches.

    When I do this:

    for curve in curves:
    x = curve[:, 0]
    y = curve[:, 1]
    z = curve[:, 2]
    tck, u = splprep([x,y,z], s=0) # scipy.interpolate.splprep
    unew = np.linspace(0, 1, 100)
    out = splev(unew, tck)
    ax.plot(out[0], out[1], out[2], label=f'B-spline Curve {idx+1}')


    Result: splprep return ValueError: Invalid inputs.

    I know this is an error that occurs when the splprep function encounters points where the inputs are repeated (it's ok to run splprep with a different curve alone), but the number of curves is unknown and I need 'for' to control the number of executions. how to fix it? ty!

    Continue reading...

Compartilhe esta Página