By fitting the data using spline, I have created a curve.
sp = SplineFit[data1, Cubic]
I am trying to divide this curve into small segments of equal length. To do so, I am trying to calculate the length of the curve using:
NIntegrate[Sqrt[1 + sp'[z]^2], {z, 0, 34}]
I get:
NIntegrate::inumr: "The integrand \!\(\*SqrtBox[
RowBox[{\"1\", \"+\", SuperscriptBox[
RowBox[{SuperscriptBox[TemplateBox[{\"\\\"SplineFunction[\\\"\",\"Cubic\",\"\\\", \\\"\",RowBox[{\"{\", RowBox[{\"0.`\", \",\", \"34.`\"}], \"}\"}],\"\\\", \\\"\",\"\\\"<>\\\"\",\"\\\"]\\\"\"},
\"RowDefault\"], \"\[Prime]\",
MultilineFunction->None], \"[\", \"z\", \"]\"}], \"2\"]}]]\) has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,34}}."
I am new to Mathematica and I really do not understand how splines work. I am trying to use the technique mentioned in How do I split up a curve into chords of equal length? to divide the curve into equal segments.
SplineFit
seems to be somewhat deprecated. We now haveInterpolation
,BezierFunction
,BSplineFunction
-- maybe others I don't recall. TheSplineFunction
does not seem to be symbolically differentiable. $\endgroup$xydata = Table[{t Cos[t], t Sin[t]}, {t, 0., 10}]; pf = Interpolation[ MapThread[{{#1}, #2} &, {Rescale@Range@Length@xydata, xydata}], Method -> "Spline"]; ParametricPlot[pf[t], {t, 0, 1}]
. Note the data forInterpolation
should be in the formTable[{{t}, {x, y}}, {t,...}]
-- note the braces carefully. $\endgroup$