3
$\begingroup$

I have a sequence $\{(x_k, y_k, z_k)\}_{k=1}^n \subset \mathbb{R}^3$, all points along a path represented by the function $\gamma \colon \mathbb{R} \to \mathbb{R}^3$, which maps the distance along the path to a location in 3D space.

Is there any way for Mathematica to output an interpolation parametrized like $\gamma$, and has the sequence as a subset of its range?

$\endgroup$
10
$\begingroup$

You can do it with one Interpolation, if you specify the parameter values for each point. Below I made the interpolated points correspond to equally spaced values (Range[0, 1, 1/(Length[pts] - 1)]).

SeedRandom[1];
pts = Accumulate[RandomReal[{-1, 1}, {5, 3}]]
(*
   {{0.634779, -0.777161, 0.579052},
    {0.0103853, -1.29444, -0.28947},
    {0.0948785, -1.83213, -0.497458},
    {0.495826, -2.40848, -0.000144566},
    {0.341527, -2.91349, 0.954199}}
*)

ifn = Interpolation[
   Transpose[{N@Range[0, 1, 1/(Length[pts] - 1)], pts}]];

Show[
 ParametricPlot3D[ifn[t], {t, 0, 1}, PlotStyle -> Thick],
 Graphics3D[{Red, PointSize[Large], Point[pts]}]
 ]

Mathematica graphics

$\endgroup$
  • $\begingroup$ I guess we should get used to the new default color scheme ;) $\endgroup$ – shrx Dec 26 '13 at 17:29
  • $\begingroup$ A better approach would be to use centripetal or chord-length parametrization on the points, since they are based on the configuration of the points themselves, as opposed to uniformly spaced values. $\endgroup$ – J. M. will be back soon Jul 25 '15 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.