[SciPy-User] Arc length of parametric spline

Pauli Virtanen pav at iki.fi
Thu May 11 15:05:08 EDT 2017


Kenny Vermeers kirjoitti 11.05.2017 klo 12:12:
> In order to do this I need the splines dx/dt and dy/dt,. I was going to
> do this as follows
> tck, u = interpolate.splprep([x, y])
> dspl = interpolate.splder(tck)
> hoping to get dx/dt and dy/dt and then solving the integral.
> Unfortunately that doesn't work since splder doesn't seem to accept
> parametric splines. Do you have any suggestions on how to get the spline
> parameter from 0 to arclen?

You can grab the x(u) and y(u) splines from the output of splprep. It is
a bit ugly because splprep has a different padding convention than splrep.

t, c, k = tck
cx = np.concatenate([c[0], np.zeros(len(t) - len(c[0]))])
cy = np.concatenate([c[1], np.zeros(len(t) - len(c[1]))])
tck_x = (t, cx, k)
tck_y = (t, cy, k)


More information about the SciPy-User mailing list