(* Copyright 1993 Alfred Gray *)

BeginPackage["CURVES3D`"]

    ast3d::usage="t->ast3d[n,a,b][t] is a space curve analog of the
plane curve astroid."

    bicylinder::usage="t->bicylinder[a,b,c][t] is a parametrization of the
intersection of a cylinder of radius a and a cylinder of radius b.  One
component is obtained by taking pm = +1, the other by taking pm = -1."

    besselcurve::usage="t->besselcurve[a,b,c][t] is a space curve
whose components are Bessel functions."

    cubicalellipse::usage="t->cubicalellipse[a,b,c,d,e,f,pm][t] is a
cubical ellipse for pm = 1 and a cubical hyperbola for pm = -1."

   eightknot::usage="t->eightknot[t] is a parametrization of the eight
knot."

    helix::usage="t->helix[a,b][t] is a circular helix of radius a and slant b.
t->helix[a,b,c][t] is an elliptical helix of slant c."

    line3d::usage="t->line3d[a1,b1,c1,a2,b2,c2][t] is a parametrized line in
R^3 with line3d[a1,b1,c1,a2,b2,c2][0]={a2,b2,c2} and
line3d[a1,b1,c1,a2,b2,c2]'[0]={a1,b1,c1}."

    lissajous3d::usage="t->lissajous3d[n,d,a,b,c][t] is a space curve
analog of lissajous curve."

    loxodrome::usage="t->loxodrome[a][t] is a loxodrome on a sphere
of radius a. It is a curve whose angle with each meridian is constant."

    spherespiral::usage="t->spherespiral[a][m,n][t] is a spiral of type
(m,n) on an sphere of radius a."

    torusknot::usage="t->torusknot[a,b,c][p,q][t] is a torus knot of
type (p,q) on an elliptical torus of type (a,b,c)."

    twicubic::usage="t->twicubic[t] is the twisted cubic
t->{t,t^2,t^3}."

    veryflat::usage="t->veryflat[1][t] is the curve t->{t,0,5*E^(-1/t^2)}.
t->veryflat[2][t] is the curve t->If[t<0,{t,5*E^(-1/t^2),0},
If[t==0,{0,0,0},{t,0,5*E^(-1/t^2)}]].  These curves have
the same curvature and torsion."

    viviani::usage="t->viviani[a][t] is a Viviani curve on a sphere
of radius a."

Begin["`Private`"]

    ast3d[n_,a_,b_][t_]:= {a*Cos[t]^n,b*Sin[t]^n,Cos[2*t]}

    besselcurve[a_,b_,c_][t_]:=
         {BesselJ[a,t],BesselJ[b,t],BesselJ[c,t]}

    bicylinder[a_,b_,pm_][t_]:= {a*Cos[t],a*Sin[t],
                                 pm*Sqrt[b^2 - a^2*Sin[t]^2]}

    cubicalellipse[a_,b_,c_,d_,e_,f_,pm_][t_]:=
           {a*t,b*t + c*t^2,d*t + e*t^2 + f*t^3}/(1 + pm*t^2)

    eightknot[t_]:=
        {10*(Cos[t] + Cos[3*t]) + Cos[2*t] + Cos[4*t],
         6*Sin[t] + 10*Sin[3*t],
         4*Sin[3*t]*Sin[5*t/2] + 4*Sin[4*t] - 2*Sin[6*t]}

    helix[a_,c_][t_]:= {a*Cos[t],a*Sin[t],c*t}

    helix[a_,b_,c_][t_]:= {a*Cos[t],b*Sin[t],c*t}

    line3d[a1_,b1_,c1_,a2_,b2_,c2_][t_]:=
         {a1*t + a2,b1*t + b2,c1*t + c2}

    lissajous3d[n_,d_,a_,b_,c_][t_]:=
         {a*Sin[n*t + d],b*Sin[t],c*Cos[t]} 

    loxodrome[a_][t_]:=
         {Cos[Log[t]]*Sin[2*ArcTan[t]],
          Sin[Log[t]]*Sin[2*ArcTan[t]],
          Cos[2*ArcTan[t]]}

    spherespiral[a_][m_,n_][t_]:=
               a*{Cos[m*t]*Cos[n*t],Sin[m*t]*Cos[n*t],Sin[n*t]}

    torusknot[a_,b_,c_][p_,q_][t_]:=
         {(a + b*Cos[q*t])*Cos[p*t],
          (a + b*Cos[q*t])*Sin[p*t],c*Sin[q*t]}

    twicubic[t_]:= {t,t^2,t^3}

    veryflat[1][t_]:= {t,0,5*E^(-1/t^2)}

    veryflat[2][t_]:= If[t<0,{t,5*E^(-1/t^2),0},
                     If[t==0,{0,0,0},{t,0,5*E^(-1/t^2)}]]

    viviani[a_][t_]:= a*{1 + Cos[t],Sin[t],2*Sin[t/2]}

End[]

EndPackage[]
