This my question is concerned with previous about Tube cross-section. Let's use the same pts as in that question.
pts = {{0.`, 0.`, 0.`}, {7.497665500157259`*^-14,
0.00036555534709634656`,
0.041887873232098444`}, {2.9988378071419946`*^-13,
0.0014621100333863195`,
0.08376298663421493`}, {6.746528662189823`*^-13,
0.0032893300277940163`,
0.12561258426325045`}, {1.1991697498398906`*^-12,
0.005846658724918654`,
0.16742391794868797`}, {1.8732746539195436`*^-12,
0.009133317114586991`,
0.20918425117592362`}, {2.696762233490476`*^-12,
0.013148304019154402`,
0.25088086296604745`}, {3.669381638827055`*^-12,
0.017890396398482316`,
0.2925010517508915`}, {4.790836591859004`*^-12,
0.02335814972249914`,
0.33403213924216535`}, {6.0607854764232425`*^-12,
0.029549898411231134`,
0.37546147429349974`}, {7.478841442326563`*^-12,
0.03646375634216925`,
0.41677643675422266`}, {9.044572523187444`*^-12,
0.04409761742481735`,
0.45796444131369324`}, {1.0757501768021084`*^-11,
0.052449156242246726`,
0.499012941335023`}, {1.26171073865276`*^-11, 0.06151582875946169`,
0.5399094326770161`}, {1.4622822908039118`*^-11,
0.07129487309836018`,
0.5806414575031648`}, {1.6774037354077335`*^-11,
0.08178331037905351`, 0.6211966080765395`}, {1.9070095424469`*^-11,
0.09297794562728895`,
0.6615625305394178`}, {2.1510297696962602`*^-11,
0.10487536874769866`,
0.7017269286765003`}, {2.4093900840285483`*^-11,
0.11747195556257856`,
0.7416775676605682`}, {2.6820117840576448`*^-11,
0.13076386891588063`,
0.7814022777794407`}, {2.9688118241124915`*^-11,
0.14474705984208247`, 0.8208889581430966`}}
Now I need to construct parametric form of the curve. One method is using Interpolation:
path[u_] = Interpolation[#, u] & /@ Transpose[pts]
The main advantage of Interpolation is that path is going through all the points of pts exactly. Then I use code from @SquareOne:
frenet[u_] = FrenetSerretSystem[path[u], u][[2]]; // AbsoluteTiming
transform[u_] :=
Composition[TranslationTransform[pts[[u]]],
FindGeometricTransform[
frenet[u], {{0, 0, 1}, {1, 0, 0}, {0, 1, 0}}][[2]]];
I included AbsoluteTiming here to measure time of operation. And I see that frenet[u_] takes significant time, about 0.27--0.3 sec on my machine.
Another approach is using BSplineFunction:
path1[u_] := BSplineFunction[#][u] & /@ (Transpose@pts);
frenet1[u_] = FrenetSerretSystem[path1[u], u][[2]]; // AbsoluteTiming
This is much faster, it takes about 0.09--0.1 sec on my machine, i.e. BSplineFunction is 2.5--3 times faster than Interpolation. Why is this difference in speed? Can I speed-up Interpolation if I want to use it because of (as I think, probably wrong) it gives more accurate approximation.
Thank you.
Method -> "Spline"inInterpolation[]? – J. M.'s missing motivation Dec 19 '16 at 10:12path[u_] = Interpolation[#, u, Method -> "Spline"] & /@ Transpose[pts], thenfrenet[u_]takes about 0.32--0.35 sec, more or the same time or even longer. – Alx Dec 19 '16 at 10:28FrenetSerretSystem, which is done only once for each set ofpts?Interpolationitself is fast, but it isFrenetSerretSystemthat takes the extra time when analyzing (I surmise)InterpolatingFunctioncompared to analyzingBSplineFunction. – Michael E2 Dec 19 '16 at 18:33