(*:Title: CURVES2D *)

(*:Author: Alfred Gray *)

(* Copyright 1994  by Alfred Gray *)

(*:Package Version: 1.0 *)

(*:Mathematica Version: 2.2 *)

(*:Summary: 
This package consists of definitions of parametrizations of plane curves.
*)

(*:Keywords:
agnesi, archimedesspiral, astroid, bowtie, cardioid,  catenary, cayleysextic, 
circle, circleinvolute,  cissoid, clothoid, clothoidprime, cnccoprofile,  
cnchyprofile, cochleoid, conchoid, cothspiral,  cpcprofile, cubicparabola, 
cycloid, deltoid,  diamond, eight, ellipse, epicycloid, epitrochoid,  
fermatspiral, folium, hyperbola, hyperbolicspiral,  hypocycloid, hypotrochoid, 
lemniscate, limacon, line,  lissajous, lituus, logistic, logspiral, nephroid,  
nielsenspiral, parabola, parabolicspiral, piriform, rose, sc, scarab,  
serpentine, spring, strophoid, tanhspiral, tractrix, triangle,  trisectrix, 
tschirnhausen, zcprofile
*)

Print["For a list of parametrized plane curves type curves2d."]

BeginPackage["CURVES2D`"]

    curves2d:=Print[Select[Names["CURVES2D`*"],#!="curves2d"&]]

    agnesi::usage="t->agnesi[a][t] is the parametrized curve
whose implicit equation is x^2*y==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."

    bowtie::usage="t->bowtie[a,b][t] is a parametrized curve
whose shape is a bowtie."

     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 2*a. It has
the polar equation r=2*a*(1 + Cos[theta]).  A cardioid is a special case
of an epicycloid."

    cardioidunitspeed::usage="s->cardioidunitspeed[c][s] is a unit-speed
parametrization of a cardioid."

    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}."

    catenaryunitspeed::usage="s->catenaryunitspeed[c][s] is a unit-speed
parametrization of a catenary."

    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."

    circleunitspeed::usage="s->circleunitspeed[a][s] is a unit-speed
parametrization of a circle."

    circleinvolute::usage="t->circleinvolute[n,a][t] is the nth
involute starting at {a,0} of the circle t->{a*Cos[t],a*Sin[t]}.
t->circleinvolute[a][t] is the same as t->circleinvolute[1,a][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.
t->clothoid[1,a][t] is the ordinary clothoid, also known as 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 -a^-2 of conic type.
The parameter pm is plus or minus 1."

    cnchyprofile::usage="t->cnchyprofile[pm,a,b][t] is a profile curve for a
surface of revolution of constant negative curvature -a^-2 of hyperboloid type.
The parameter pm is plus or minus 1."

    cochleoid::usage="t->cochleoid[n,a][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."

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

    cpcprofile::usage="t->cpcprofile[pm,a,b][t] is a profile curve for a
surface of revolution of constant positive curvature a^-2.  The parameter
pm is plus or minus 1. There are 3 cases: football type (a>b),
sphere (a=b), barrel type (a<b)." 

    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] is the locus of points traced out by
a point on a circle of 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 curtate if a > b."

    cycloidunitspeed::usage="s->cycloidunitspeed[a,a][s] is a unit-speed
parametrization of a cycloid."

    deltoid::usage="t->deltoid[a][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
t->diamond[a][t] that is similar to t->astroid[n,a,b][t]."

    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)."

    epicycloidunitspeed::usage="s->epicycloidunitspeed[a,b][s] is a unit-speed
parametrization of an epicycloid."

    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 of
radius a, where t is positive. t->fermatspiral[n,a][t] is a
spiral of Fermat of radius a and index n, where t may be positive or
negative. Special cases are: fermatspiral (n=1/4), lituus (n=3/4),
archimedesspiral (n=(m-1)/(2m))."

    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 of radius a. 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
Bowditch curve."

    lituus::usage="t->lituus[a][t] is the lituus spiral of radius a.
It is a trumpet-shaped curve that is the locus of points p such that the
square of distance of p from the origin is inversely proportional to the
angle theta that p makes with the horizontal axis.  The polar equation
is r=a*(theta)^(-1/2)."

    logistic::usage="t->logistic[k,a,b][t] is the logistic curve used to
model growth in biological populations for which saturation occurs."

    logspiral::usage="t->logspiral[a,b][t] is the logspiral of radius a
and slant b.  The polar equation is r=a*E^(b*theta)."

    nephroid::usage="t->nephroid[a][t] is a nephroid or kidney shaped
curve. The implicit equation is (x^2 + y^2 - 4*a^2)^3 - 108*a^4*y^2==0.
A nephroid is a special case of an epicycloid."

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

    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*a*y."

    parabolicspiral::usage="t->parabolicspiral[n,a,b][t] is a
parabolic spiral of radius a, offset b and index n, where t may be
positive or negative. Special cases are: fermatspiral (b=0),
lituus (n=3/4,b=0), archimedesspiral (n=(m-1)/(2m),b=0)."

    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 2*n petals if n is even.  The polar equation is
r=a*Cos[n*theta]."

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

    scarab::usage="t->scarab[t] is a parametrization of a scarab."

    serpentine::usage="t->serpentine[a,b][t] is a serpentine curve."

    spring::usage="t->spring[a,b,v][t] is a plane curve which resembles a
spring. It is the projection of t->helix[a,b][t] onto a plane whose normal
makes an angle v with the z-axis."

    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]."

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

    tractrix::usage="t->tractrix[a][t] is a tractrix. It represents the path
of a particle P pulled by an inextensible string whose end moves along a line.
The evolute of a catenary is a tractrix. A tractrix is the profile curve of
a surface of revolution of constant Gaussian curvature -a^-2."

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

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

    tschirnhausen::usage="t->tschirnhausen[n,a][t] is a parametrization of
Tschirnhausen's cubic."

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

Begin["`Private`"]

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

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

    astroid[a_][t_]:= {a*Cos[t]^3,a*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}

    bowtie[a_, b_][t_]:= {a*(1 + Cos[t]^2)*Sin[t],
                          (b + Sin[t]^2)*Cos[t]}
  
    cardioid[a_][t_]:= {2*a*Cos[t]*(1 + Cos[t]),
                        2*a*Sin[t]*(1 + Cos[t])} 
    
    cardioidunitspeed[a_][s_]:=
        {2*a*Cos[2*ArcSin[s/(8*a)]]*(1 + Cos[2*ArcSin[s/(8*a)]]), 
         2*a*(1 + Cos[2*ArcSin[s/(8*a)]])*Sin[2*ArcSin[s/(8*a)]]}

    cassini[a_, b_, pm1_, pm2_][t_] := 
      {pm1*Sqrt[b^2*Cos[2*t] + pm2*Sqrt[b^4*Cos[2*t] + a^4 - b^4]]*Cos[t],
       pm1*Sqrt[b^2*Cos[2*t] + pm2*Sqrt[b^4*Cos[2*t] + a^4 - b^4]]*Sin[t]}

    catenary[c_][t_]:= {c*Cosh[t/c],t} 

    catenaryunitspeed[a_][s_]:=
        {a*(1 + s^2/a^2)^(1/2), a*ArcSinh[s/a]}

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

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

    circleunitspeed[a_][s_]:= {a*Cos[s/a],a*Sin[s/a]}

    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]

    circleinvolute[a_][t_]:= circleinvolute[1,a][t]

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

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

    clothoidprime[n_,a_][t_]:=
         {a*Sin[t^(n+1)/(n+1)],a*Cos[t^(n+1)/(n+1)]}
       
    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],a*(Sin[t]/t)^n*Sin[t]}

    conchoid[a_,b_][t_]:= {b + a*Cos[t],b*Tan[t] + a*Sin[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])}

    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]}

    cycloidunitspeed[a_,a_][s_]:=
        {4*a*ArcSin[(s/(8*a))^(1/2)] - 
         a*Sin[4*ArcSin[(s/(8*a))^(1/2)]], 
         a - a*Cos[4*ArcSin[(s/(8*a))^(1/2)]]}

    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]}

    epicycloidunitspeed[a_,b_][s_]:=
    {(a + b)*Cos[4*b*ArcSin[((a*s)/(b*(8*a + 8*b)))^(1/2)]/a] - 
      b*Cos[4*(a + b)*ArcSin[((a*s)/(b*(8*a + 8*b)))^(1/2)]/a],
      (a + b)*Sin[4*b*ArcSin[((a*s)/(b*(8*a + 8*b)))^(1/2)]/a] -
       b*Sin[4*(a + b)*ArcSin[((a*s)/(b*(8*a + 8*b)))^(1/2)]/a]}

    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],a*t^(1/2)*Sin[t]}

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

    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]/(1 + Sin[t]^2),
          a*Sin[t]*Cos[t]/(1 + Sin[t]^2)}

    limacon[a_,b_][t_]:= {(2*a*Cos[t] + b)*Cos[t],
                          (2*a*Cos[t] + b)*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]],
                      a*t/(t^2)^(3/4)*Sin[Sqrt[t^2]]}

    logistic[k_,a_,b_][t_]:= {t,k/(1 + E^(a + b*t))}

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

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

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

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

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

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

    parabolicspiral[n_,a_,b_][t_]:=
        {(a*t/(t^2)^n + b)*Cos[Sqrt[t^2]],
        (a*t/(t^2)^n + b)*Sin[Sqrt[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],a*Cos[n*t]*Sin[t]}

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

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

    serpentine[a_,b_][t_]:= {t,a*t/(1 + b*t^2)}

    spring[a_,b_,v_][t_]:=
        {a*Cos[t], a*Cos[v]*Sin[t] + b*t*Sin[v]}

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

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

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

    tractrix[a_][t_]:= {a*Sin[t],a*(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*(1 - 4*Cos[t]^2),a*(1 - 4*Cos[t]^2)*Tan[t]}

    tschirnhausen[n_,a_][t_]:={a*Cos[t]/Cos[t/3]^n,
                               a*Sin[t]/Cos[t/3]^n}

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

End[]

EndPackage[]


