MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Tangent on 3d cubic spline

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25606] Re: [mg25592] Tangent on 3d cubic spline
  • From: "Christopher J. Purcell" <purcell at drea.dnd.ca>
  • Date: Wed, 11 Oct 2000 03:50:43 -0400 (EDT)
  • References: <200010100143.VAA14039@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

I have not been able to get SplineFit to handle 3D data sets, and the 
documentation only discusses splines in the plane. The following does 
the job, sorry about being rather longwinded, but you get what you 
pay for.

Clear[Interpolation3D, TangentInterpolation3D, VectorListQ];

Interpolation3D::usage = "Interpolation3D[data_List,x] is
a 3D vector valued function of the parameter x with 0<x<1
which fits the array data of 3D points through which the
interpolating function space curve will pass. Uses the
built-in function Interpolation. By default equi-sampling
is used to choose the parametric coordinates
corresponding to the data vectors. You can also set
the Option Sampling->\"Chordal\" if you want to use chordal
proportional samples. If the distances between Points
are equal, then the 2 methods yield
the same results. By default cubic interpolation is
used by Interpolation but the order will
automatically be reduced if not enough Points to
define a cubic are provided.";
Clear[Interpolation3D];

TangentInterpolation3D::usage = "TangentInterpolation3D[data_List,x] is
a 3D vector valued function of the parameter x with 0<x<1
which returns the tangent vector to an interpolating function space curve \
that fits the array data of points. Uses the
built-in function Interpolation. By default equi-sampling
is used to choose the parametric coordinates
corresponding to the data vectors. You can also set
the Option Sampling->\"Chordal\" if you want to use chordal
proportional samples. If the distances between Points
are equal, then the 2 methods yield
the same results. By default cubic interpolation is
used by Interpolation but the order will
automatically be reduced if not enough Points to
define a cubic are provided.";

`VectorListQ::usage =
     "VectorListQ[vecs_List] returns True if all the vectors in a list of \
vectors are 3D and there is at least
one vector.The list is of the Form {{x1,y1,z1},{x2,y2,z2},...}.";

VectorListQ[data_List] :=
     If[Length[Dimensions[data]] == 2 && Dimensions[data][[2]] == 3 &&
         Length[data] > 0, True, False];

Options[Interpolation3D] = {Sampling -> Automatic,
       InterpolationMethod -> Automatic, InterpolationOrder -> 3};

Interpolation3D[data_List?VectorListQ, x_?AtomQ, opts___?OptionQ] :=
     Module[{distances, total, Samplingval, params},
Samplingval = Sampling /. Flatten[{opts}] /. Options[Interpolation3D];
(*Conventional equispaced Sampling*)

If[Samplingval ===
           Automatic, (params = Table[i, {i, 0, 1, 1/(Length[data] - 1)}];
total = 1;), Null];

(* Chordal proportional Sampling ...*)

If[Samplingval ==
           "Chordal", (distances =
             Table[Norm[data[[i + 1]] - data[[i]]], {i, 1, Length[data] - 1}];

total = Sum[distances[[i]], {i, 1, Length[distances]}];
params = FoldList[Plus, 0, distances];), Null];
    {ListInterpolation[data[[All, 1]], {params/total}, opts][x],
         ListInterpolation[data[[All, 2]], {params/total}, opts][x],
         ListInterpolation[data[[All, 3]], {params/total}, opts][x]}];

TangentInterpolation3D[data_List?VectorListQ, x_] :=
     Module[{vec}, (vec = D[Interpolation3D[data, xx], xx] /. xx -> x;
vec/Sqrt[vec.vec])];

data = Table[{Sin[2 Pi t], Cos[2 Pi t], t}, {t, 0, 2, .1}]; (*
   some points along a helix as an example *)

ParametricPlot3D[Interpolation3D[data, x], {x, 0, 1}, PlotPoints -> 33];

Needs["Graphics`PlotField3D`"]

ListPlotVectorField3D[
     Table[{Interpolation3D[data, u], .2 *
           TangentInterpolation3D[data, u]}, {u, 0, 1, .025}],
     AxesLabel -> {"X", "Y", "Z"}, Boxed -> True, Axes -> True,
     VectorHeads -> True];



>Hi!
>I¥m looking for a way to find tangents to points
>on a SplineFunction.
>I have a dataset of 3-dimensional coordinates
>and use SplineFit to generate a
>SplineFunction that can be plotted with
>ParametricPlot3D.
>
>How do a calculate tangent vectors for my
>SplineFunction at given points?
>
>Thanx in advance
>
>Philipp
>
>gunz at treangeli.at
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.

-- 
Dr. Christopher J. Purcell
Group Leader/Transducers
Defence Research Establishment Atlantic
9 Grove St., Dartmouth, NS Canada B2Y 3Z7
Tel: 902-426-3100-x389
Fax: 902-426-9654


  • Prev by Date: Re: Harmonic Analysis (Harmonic Matching) (Symbolic) in Mathematica
  • Next by Date: careers with mathematica?
  • Previous by thread: Tangent on 3d cubic spline
  • Next by thread: Tangents on a 3d-cubic-spline