Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
Related: Higher order periodic interpolation (curve fitting), although the question is slightly different. –  Michael E2 Dec 26 '13 at 17:26
add comment

1 Answer 1

up vote 7 down vote accepted

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

share|improve this answer
    
I guess we should get used to the new default color scheme ;) –  shrx Dec 26 '13 at 17:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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