(* Copyright 1993 Alfred Gray *)

BeginPackage["CURVES2D`"]

    agnesi::usage="t->agnesi[a][t] is the parametrized curve
whose implicit equation is x^2y = 4*a^2*(2*a - y)."

   archimedesspiral::usage="t->archimedesspiral[n,a][t] is the
spiral of Archimedes of radius a and index n."

    astroid::usage="t->astroid[a][t] is the parametrized curve
whose implicit equation is x^(2/3) + y^(2/3) ==a^(2/3).
t->astroid[a,b][t] is the parametrized curve whose implicit equation is
(x/a)^(2/3)+(y/b)^(2/3)==1.  t->astroid[n,a,b][t] is the
parametrized curve whose implicit equation is (x/a)^n + (y/b)^n==1."

     cardioid::usage="t->cardioid[a][t] is a heart-shaped curve
that is traced by a point on the circumference of a circle
rolling around a fixed circle of the same radius. It has
the polar equation r=a*(1 + Cos[theta])."

    catenary::usage="t->catenary[c][t] is the curve formed by a perfectly
flexible inextensible chain of uniform density hanging from two supports.
It is given by t->{c*Cosh[t/c],t}."

    cayleysextic::usage="t->cayleysextic[a][t] is
Cayley's sextic curve."

    circle::usage="t->circle[a][t] is a circle centered at the origin of
radius a. The nonparametric form is x^2 + y^2==a^2."

    circleinvolute::usage="t->circleinvolute[n,a][t] is the nth
involute starting at {a,0} of the circle t->a*{Cos[t],Sin[t]}."  

    cissoid::usage="t->cissoid[a][t] is an ivy-shaped curve
whose implicit equation is x^3 + x y^2 - 2*a*y^2==0."

    clothoid::usage="t->clothoid[n,a][t] is the nth clothoid.
clothoid[1,a][t] is the ordinary clothoid, also known as spiral of
Cornu or Euler's spiral."

    clothoidprime::usage="t->clothoidprime[n,a][t] is the
velocity of the nth clothoid."

    cnccoprofile::usage="t->cnccoprofile[pm,a,b][t] is a profile curve for a
surface of revolution of constant negative curvature of conic type."

    cnchyprofile::usage="t->cnchyprofile[pm,a,b][t] is a profile curve for a
surface of revolution of constant negative curvature of hyperbolic type."

    cochleoid::usage="t->cochleoid[n,b][t] is the parametrized curve
whose polar equation is r=a*(Sin[theta]/theta)^n."

    conchoid::usage="t->conchoid[a,b][t] is the parametrized curve
whose implicit equation is (x^2 + y^2)*(x - b)^2=a^2*x^2."

    cpcprofile::usage="t->cpcprofile[pm,a,b][t] is a profile curve for a
surface of revolution of constant positive curvature pm is plus or minus 1."

    cubicparabola::usage="t->cubicparabola[a,b,c,d][t] is the general cubic
parabola whose implicit equation is y==a*x^3 + b*x^2 + c*x + d."

    cycloid::usage="t->cycloid[a,b][t] the locus of points traced out by
a point on a circle radius b when a concentric circle of radius a rolls
without slipping along a straight line.  The cycloid is called prolate
if b > a and curate if a > b."

    deltoid::usage="t->deltoid[t] is a parametrized curve which resembles
a delta."

    diamond::usage="t->diamond[a][t] is the parametrized curve whose
shape is a diamond. t->diamond[n,a,b][t] is a generalization of
diamond[a][t] that is similar to astroid[n,a,b]."

    eight::usage="t->eight[t] is a parametrized curve which resembles
a figure eight."

    ellipse::usage="t->ellipse[a,b][t] is an ellipse centered at the origin.
The nonparametric form is x^2/a^2 + y^2/b^2==1."

    epicycloid::usage="t->epicycloid[a,b][t] is the parametrized curve
that is traced out by a point P on the circumference of a circle
(of radius b) rolling outside another circle (of radius a).
Special cases are: cardioid (b=a), nephroid (b=a/2)."

    epitrochoid::usage="t->epitrochoid[a,b,h][t] is the parametrized curve
that is traced out by a point P attached to a circle (of radius b) rolling
outside another circle (of radius a).  Let h be the distance from P to the center of the moving circle. Special cases are: circle (a=0), limacon  (a=b),
epicycloid (h=b), cardioid (h=b=a), nephroid (h=b=a/2).  There are a/b loops.
For an epicycloid the loops degenerate to points."

    fermatspiral::usage="t->fermatspiral[a][t] is a
spiral of Fermat. a may be positive or negative."

    folium::usage="t->folium[t] is the folium of Descartes.
The nonparametric form is x^3 + y^3 - 3*x*y==0."

    hyperbola::usage="t->hyperbola[a,b][t] is a hyperbola centered at
the origin.  The nonparametric form is x^2/a^2 - y^2/b^2==1."

    hyperbolicspiral::usage="t->hyperbolicspiral[a][t] is a
hyperbolic spiral. It is a special case of the spiral of Archimedes."

    hypocycloid::usage="t->hypocycloid[a,b][t] is the parametrized curve
that is traced out by a point P on the circumference of a circle
(of radius b) rolling inside another circle (of radius a).
Special cases are: deltoid (b=a/3), astroid (b=a/4)."

    hypotrochoid::usage="t->hypotrochoid[a,b,h][t] is the parametrized curve
that is traced out by a point P on one circle (of radius b) rolling inside
another circle (of radius a).  Let h be the distance from P to the center of
the moving circle. Special cases are: ellipse (a=2b), hypocycloid  (h=b),
deltoid (h=b=a/3), astroid (h=b=a/4).  There are a/b loops when a/b
is an integer larger than 2 and h>b. For a hypocycloid the loops degenerate
to points."

    lemniscate::usage="t->lemniscate[a][t] is the parametrized curve whose
implicit equation is (x^2 + y^2)^2==a^2*(x^2 - y^2)."

    limacon::usage="t->limacon[a,b][t] is the parametrized curve whose
implicit equation is (x^2 + y^2 - 2*a*x)^2==b^2*(x^2 + y^2)."

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

    lissajous::usage="t->lissajous[n,d,a,b][t] is a Lissajous or
Bodwitch curve."

    lituus::usage="t->lituus[a][t] is the
lituus spiral of radius a."

    logspiral::usage="t->logspiral[a,b][t] is the logspiral of radius a
and slant b."

    nephroid::usage="t->nephroid[a][t] is a nephroid or kidney shaped
curve."

    parabola::usage="t->parabola[a][t] is the vertical parabola with
vertex at the origin, focus at {0,a} and directrix t->{t,-a}.
The nonparametric form is x^2==4*y*a."

    piriform::usage="t->piriform[a,b][t] is the pear-shaped curve whose
implicit equation is  a^4*y^2 - b^2*x^3*(2*a - x)==0."

    rose::usage="t->rose[n,a][t] is a rose of radius a with n petals if
n is odd and 2n petals if n is even."

    sc::usage="t->sc[t] is the semicubical parabola t->{t^2,t^3}
The nonparametric form is y^2==x^3."

    strophoid::usage="t->strophoid[a][t] is the parametrized curve whose
implicit equation is y^2(a-x)=x^3.  t->strophoid[m,a][t]
is the parametrized curve whose
implicit equation is y^2(a-x)=x^2*(a*m + x).
The case m=0 is the cissoid t->cissoid[a/2][t]
and the case m=1 is the strophoid t->strophoid[a][t]."

    cothspiral::usage="t->cothspiral[a][t]}  is the
hyperbolic cotangent spiral of radius a."

    tanhspiral::usage="t->tanhspiral[a][t]}  is the
hyperbolic tangent spiral of radius a."

    nielsenspiral::usage="t->nielsenspiral[a][t]} is Nielsen's spiral
of radius a."

    tractrix::usage="t->tractrix[a][t] is a tractrix.  It is the profile curve
of a surface of revolution of Gaussian curvature -a^-1."

    triangle::usage="t->triangle[t] is a parametrization of an equilateral
triangle."

    trisectrix::usage="t->trisectrix[a][t] is the trisectrix of
Maclaurin."

    zcprofile::usage="t->zcprofile[pm,a,c][t] is the profile curve of a
generalized helicoid of zero Gaussian curvature. pm is +1 or -1."

Begin["`Private`"]

    agnesi[a_][t_]:= 2*a*{Tan[t],Cos[t]^2}

    archimedesspiral[n_,a_][t_]:= a*t^(1/n)*{Cos[t],Sin[t]}

    astroid[a_][t_]:= a*{Cos[t]^3,Sin[t]^3}              

    astroid[a_][t_]:= a*{Cos[t]^3,Sin[t]^3}              

    astroid[a_,b_][t_]:= {a*Cos[t]^3,b*Sin[t]^3}

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

    cardioid[a_][t_]:= {2*a*Cos[t]*(1 + Cos[t]),
                        2*a*Sin[t]*(1 + Cos[t])} 
    
    catenary[c_][t_]:= {c*Cosh[t/c],t} 

    cayleysextic[a_][t_]:=
          {4*a*Cos[t/2]^4*(-1 + 2*Cos[t]),
           4*a*Cos[t/2]^3*Sin[3*t/2]}

    circleinvolute[n_,a_][t_]:= Module[{tmp1,tmp2},
         tmp1=E^(I*tt)Normal[Series[E^(-I*tt),{tt,0,n}]];
         tmp2=a*ComplexExpand[{Re[tmp1],Im[tmp1]}];
         tmp2 /. tt->t]

    circle[a_][t_]:= {a*Cos[t],a*Sin[t]}

    cissoid[a_][t_]:= {2*a*t^2/(1 + t^2),2*a*t^3/(1 + t^2)}

    clothoidprime[n_,a_][t_]:=
         a*{Sin[t^(n+1)/(n+1)],Cos[t^(n+1)/(n+1)]}

    clothoid[n_,a_][t_]:=
         Integrate[clothoidprime[n,a][tt],{tt,0,t}]

       
    cnccoprofile[pm_,a_,b_][t_]:=
       {pm*b*Sinh[t/a],-I*Sqrt[a^2 - b^2] EllipticE[I*t/a,
                       -b^2/Sqrt[a^2 - b^2]]}

    cnchyprofile[pm_,a_,b_][t_]:=
       {pm*b*Cosh[t/a],-I*a*EllipticE[I t/a,-b^2/a^2]}

    cochleoid[n_,a_][t_]:= a*(Sin[t]/t)^n*{Cos[t],Sin[t]}

    conchoid[a_,b_][t_]:= {b + a*Cos[t], b*Tan[t] + a*Sin[t]}

    cpcprofile[pm_,a_,b_][t_]:=
       {pm*b*Cos[t/a],a*EllipticE[t/a,b^2/a^2]}

    cubicparabola[a_,b_,c_,d_][t_]:= {t,a*t^3 + b*t^2 + c*t + d}

    cycloid[a_,b_][t_]:= {a*t - b*Sin[t],a - b*Cos[t]}

    deltoid[a_][t_]:=
       {2*a*Cos[t]*(1 + Cos[t]) - a,2*a*Sin[t]*(1 - Cos[t])}

    diamond[a_][t_]:=
        {a*Cos[t]*Sqrt[Cos[t]^2], a*Sin[t]*Sqrt[Sin[t]^2]}

    diamond[n_,a_,b_][t_]:=
        {a*Sqrt[Cos[t]^2]^(n-1)*Cos[t],
         b*Sqrt[Sin[t]^2]^(n-1)*Sin[t]}

    eight[t_]:= {Sin[t],Sin[t]*Cos[t]}

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

    epicycloid[a_,b_][t_]:=
            {(a + b)*Cos[t] - b*Cos[((a + b)/b)*t],
             (a + b)*Sin[t] - b*Sin[((a + b)/b)*t]}

    epitrochoid[a_,b_,h_][t_]:=
            {(a + b)*Cos[t] - h*Cos[((a + b)/b)*t],
             (a + b)*Sin[t] - h*Sin[((a + b)/b)*t]}

    fermatspiral[a_][t_]:= a*t^(1/2)*{Cos[t],Sin[t]}

    folium[t_]:= {3*t/(1 + t^3),3*t^2/(1 + t^3)}

    hyperbola[a_,b_][t_]:= {a*Cosh[t],b*Sinh[t]}

    hyperbolicspiral[a_][t_]:= {a/t*Cos[t],a/t*Sin[t]}

    hypocycloid[a_,b_][t_]:=
            {(a - b)*Cos[t] + b*Cos[((a - b)/b)*t],
             (a - b)*Sin[t] - b*Sin[((a - b)/b)*t]}

    hypotrochoid[a_,b_,h_][t_]:=
            {(a - b)*Cos[t] + h*Cos[((a - b)/b)*t],
             (a - b)*Sin[t] - h*Sin[((a - b)/b)*t]}

    lemniscate[a_][t_]:=
         {a*Cos[t],a*Sin[t]*Cos[t]}/(1 + Sin[t]^2)

    limacon[a_,b_][t_]:=
         (2*a*Cos[t] + b)*{Cos[t],Sin[t]}

    limacon[n_,a_,b_][t_]:=
         (2*a*Cos[t] + b)*{Cos[t],Sin[t]}

    line[a1_,b1_,a2_,b2_][t_]:= {a1*t + a2,b1*t + b2}

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

    lituus[a_][t_]:= a*t/(t^2)^(3/4)*
                        {Cos[Sqrt[t^2]],Sin[Sqrt[t^2]]}

    logspiral[b_][t_]:= {E^(b*t)*Cos[t],E^(b*t)*Sin[t]}

    logspiral[a_,b_][t_]:= a*{E^(b*t)*Cos[t],E^(b*t)*Sin[t]}

    nephroid[a_][t_]:= a*{3*Cos[t] - Cos[3*t],3*Sin[t] - Sin[3*t]}

    nielsenspiral[a_][t_]:= a*{CosIntegral[t],SinIntegral[t]}

    parabola[a_][t_]:= {2*a*t,a*t^2}

    piriform[a_,b_][t_]:=
           {a*(1 + Sin[t]),b*Cos[t]*(1 + Sin[t])}

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

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

    tanhspiral[a_][t_]:= {Sinh[2*t]/(Cos[2*a*t] + Cosh[2*t]), 
                          Sin[2*a*t]/(Cos[2*a*t] + Cosh[2*t])}

    cothspiral[a_][t_]:= {-(Sinh[2*t]/(Cos[2*a*t] - Cosh[2*t])), 
                            Sin[2*a*t]/(Cos[2*a*t] - Cosh[2*t])}

    strophoid[a_][t_]:= a*(t^2 - 1)/(t^2 + 1)*{1,t}

    strophoid[m_,a_][t_]:= a*(t^2 - m)/(t^2 + 1)*{1,t}

    tractrix[a_][t_]:= a*{Sin[t],Cos[t] + Log[Tan[t/2]]}

    triangle[t_]:= If[t<1,t*{1,0},
         If[t<2,{1,0} + (t-1)*{-1/2,Sqrt[3]/2},
         {1/2,Sqrt[3]/2} + (t - 2)*{-1/2,-Sqrt[3]/2}]]

    trisectrix[a_][t_]:= a/Cos[t/3]*{Cos[t],Sin[t]}


    zcprofile[pm_,a_,c_][t_]:=
       {t,pm*Sqrt[a^2*t^2 - c^2] + c*ArcSin[c/(a*t)]}

End[]

EndPackage[]


