Spline(pts, order, Weight Function)
Creates a spline with given order through all points. The weight function says what should be the difference of t values for point $P_i$ and $P_{(i+1)}$ given their difference $P_{(i+1)} - P_i = (x, y)$. To get the spline you expect from "function" algorithm you should use
abs(x) + 0*y
, to get the GeoGebra's default spline you can usesqrt(x^2+y^2)
.
Its implementation may be here.
Is there a corresponding function in Mathematica? I checked the documentation of the Interpolation
and BSplineFunction
,
I don't know how to set the weight function to reproduce the result. Let's say I have points pts
like this, I generated the corresponding curve in Geogebra, which I converted into Mathematica code.
pts={{0,0},{1,1},{2,-1},{3,2},{4,1}};
cond={t<0.17,t<0.44,t<0.83,True};
val={{-11.52t^3+6.16t,-125.22t^3+9.52t},
{2.14t^3-7.05t^2+7.37t-0.07,159.41t^3-146.79t^2+34.75t-1.45},
{12.42t^3-20.72t^2+13.44t-0.97,-108.17t^3+209.4t^2-123.29t+21.93},
{-19.62t^3+58.87t^2-52.48t+17.23,115.04t^3-345.13t^2+335.92t-104.83}};
f[t_]=Piecewise[Transpose[{val,cond}]]
Show[ParametricPlot[Join[{f[t]},val]//Evaluate,{t,0,1},PlotStyle->{Black,Dashed,Dashed,Dashed,Dashed}],
Graphics[{PointSize[Large],Point[pts]}],PlotRange->{{0,5},{-2,3}}]
CubicSplineInterpolation
resource function. See also Understanding Interpolation with Cubic Splines. $\endgroup$pts = {{0, 0}, {1, 1}, {2, -1}, {3, 2}, {4, 1}}; tp = N[ResourceFunction["LeeInterpolatingNodes"][pts, 1]]; ResourceFunction["InterpolatingFunctionToPiecewise"][ResourceFunction["CubicSplineInterpolation"][Transpose[{tp, #}], "Natural"], t] & /@ Transpose[pts] // Expand
and compare with what Geogebra does. $\endgroup$