I'm trying to obtain an arc-length parametrization of a spline curve as per https://mathematica.stackexchange.com/a/8456. To do so, I need to calculate partial derivatives of such curve and then perform a FunctionInterpolation. The spline curve is continuous over its whole domain, but not differentiable at its knots (left-side derivatives are different from the right-side ones). Therefore, I'd need to create several FunctionInterpolations, each defined on an open interval between two consecutive knots.
Is that possible? And if so, how? If not, how can I overcome this limitation?
Here is the actual data I'm working on: curve = BSplineCurve[{{198.2063059205538,402.121623269958},{191.2621031932776,243.2810494404048},{350.2070352491573,246.3653323645185},{307.7702781407043,406.7480444184375},{624.1169877141547,382.0737810255268},{367.1817351705904,154.607913753287},{408.0753377407309,28.15231386462074},{192.0336877673071,89.837972346897}}, SplineDegree -> 3, SplineKnots -> {0,0,0,0,1.,2.,3.,4.,5,5,5,5}, SplineWeights -> {1,1,1,1,1,1,1,1}];
cp = curve[[1]];
dg = curve[[2]] // Values;
kn = curve[[3]] // Values;
wg = curve[[4]] // Values;
x[t_]:=Total[Table[BSplineBasis[{dg,kn},j,t],{j,0,Length[kn]-dg-2}]*wg*cp[[All,1]]]/Table[BSplineBasis[{dg,kn},j,t],{j,0,Length[kn]-dg-2}].wg;
y[t_]:=Total[Table[BSplineBasis[{dg,kn},j,t],{j,0,Length[kn]-dg-2}]*wg*cp[[All,2]]]/Table[BSplineBasis[{dg,kn},j,t],{j,0,Length[kn]-dg-2}].wg;
f[t_]:=Sqrt[(x'[t])^2+(y'[t])^2];
You can see that the interpolating function has spikes (that I'm trying to avoid) at the knot values:
FunctionInterpolation[f[t],{t,Min[kn],Max[kn]}]//Plot[#[g]-f[g],{g,Min[kn],Max[kn]},PlotRange->Full]&

Comments
Post a Comment