(*:Title: SURFS *)

(*: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 surfaces.
*)

(*:Keywords:
astell, bohdom, bour, bourpolar, boy, catalan, catalandef, 
  catenoid, catenoidasym, circularcone, circularcylinder, 
  clothoidmin, cnccosurfrev, cnchysurfrev, costa, 
  cpcsurfrev, crosscap, dini, dinitcheb, ducyc, 
  eighteight, eightsurface, ellhypcyclide, ellipsemin, 
  ellipsoid, ellipticalhyperboloidminus, 
  ellipticalhyperboloidplus, ellipticcoor, 
  ellipticparaboloid, enneper, ennepercatenoidpolar, 
  enneperpolar, exptwist, exptwistasymp, flattorus, 
  funnel, funnelasym, genhypparab, handkerchief, 
  helicoid, helicoidprin, heltocat, henneberg, 
  hyperbolicparaboloid, hyperboloid, hy2sheet, 
  kleinbottle, klein4, kuen, kuentcheb, lemniscatemin, 
  menn, mercatorellipsoid, moebcirc, moebiusstrip, 
  monkeysaddle, monkeysaddlepolar, paraboliccoor, 
  paraboliccyclide, paraboloid, perturbedms, plane, 
  plucker, pluckerpolar, pseudocrosscap, pseudosphere, 
  pstcheb, pstchebasym, rconoid, richmond, richmondpolar, 
  roman, rosemin, scherk, scherk5, shoe, sievert, sphere, 
  stereographicellipsoid, swallowtail, tetrahedral, 
  thomsen, torus, twiflat, twisphere, wallis, 
  whitneyumbrella, wrinkles
*)

Print["For a list of parametrized surfaces type surfs."]

BeginPackage["SURFS`","MINCURVS`"]

    surfs:=Print[Select[Names["SURFS`*"],#!="surfs"&]]

    astell::usage="{u,v}->astell[a,b,c][u,v] is a parametrization of
an astroidial ellipsoid with axes of lengths a, b and c."

    bohdom::usage="{u,v}->bohdom[a,b,c][u,v] is is a parametrization of a
Bohemian dome.  It is formed by moving an ellipse along a circle in a perpendicular plane so that the ellipse remains parallel to a plane."

    bour::usage="{u,v}->bour[u,v] is a parametrization of
Bour's minimal surface."

    bourpolar::usage="{r,theta}->bourpolar[n][t][r,theta]
is the polar parametrization of a 1-parameter family of minimal surfaces
such that {r,theta}->bourpolar[n][0][r,theta] is Bour's minimal surface
of degree n.  {r,theta}->bourpolar[m,n][t][r,theta]
is the polar parametrization of a 1-parameter family of minimal surfaces
such that {r,theta}->bourpolar[m,n][0][r,theta] is Bour's minimal surface
of degree {m,n}."

    boy::usage="{u,v}->boy[a,b,c][u,v] is a parametrization of
Boy's surface."

    catalan::usage="{u,v}->catalan[a][u,v] is a parametrization of
Catalan's minimal surface."

    catalandef::usage="{u,v}->catalandef[a][t][u,v] is a 1-parameter family of
minimal surfaces connecting Catalan's minimal surface to its conjugate."

    catenoid::usage="{u,v}->catenoid[c][u,v] is the minimal surface
formed by revolving a catenary."

    catenoidasym::usage="{p,q}->catenoidasym[a][p,q] is a
parametrization of a catenoid by asymptotic curves."

    circularcone::usage="{u,v}->circularcone[a,b][u,v] is a parametrization of
a circular cone of radius a and slope b/a."

    circularcylinder::usage="{u,v}->circularcylinder[a][u,v]
is a parametrization of a circular cylinder of radius a."

    clothoidmin::usage="{u,v}->clothoidmin[a][t][u,v] is a 1-parameter family
of minimal surfaces such that {u,v}->clothoidmin[a][0][u,v] is a minimal
surface containing a clothoid as a geodesic."

    cnccosurfrev::usage="{u,v}->cnccosurfrev[a,b][u,v]
is a parametrization of a surface of revolution of
constant negative curvature -a^-2 of conic type."

    cnchysurfrev::usage="{u,v}->cnchysurfrev[a,b][u,v]
is a parametrization of a surface of revolution of
constant negative curvature -a^-2 of hyperbolic type."

    costa::usage="{u,v}->costa[u,v] is a parametrization of
Costa's minimal surface."

    cpcsurfrev::usage="{u,v}->cpcsurfrev[a,b][u,v]
is a parametrization of a surface of revolution
of constant positive curvature a^-2.  There are 3 cases:
football type (a>b), sphere (a=b), barrel type (a<b)."

    crosscap::usage="{u,v}->crosscap[a][u,v] is a parametrization of a cross
cap in R^3."

    dini::usage="{u,v}->dini[a,b][u,v] is the standard parametrization of
Dini's surface of constant negative curvature -a^-2.  It is the
generalized helicoid of slant b constructed from a tractrix.
The case b=0 is the standard parametrization of a pseudosphere."

    dinitcheb::usage="{u,v}->dinitcheb[a,b][u,v] is a Tchebyshef
principal patch for Dini's surface of constant negative curvature -a^-2."

    ducyc::usage="{u,v}->ducyc[{p1,p2,p3},rho,a,b][u,v]
is a parametrization of the cyclide of Dupin with respect to a sphere 
of radius rho centered at {p1,p2,p3}.  
{u,v}->ducyc[rho,a,b][u,v] is the cyclide of Dupin with
respect to a sphere of radius rho centered at the origin."

    eighteight::usage="{u,v}->eighteight[u,v] is a parametrization of
the generalized surface of revolution formed by moving a figure eight
about a figure eight."

    eightsurface::usage="{u,v}->eightsurface[u,v] is a parametrization of
the surface formed by revolving a figure eight."

    ellhypcyclide::usage="{u,v}->ellhypcyclide[a,c,k][u,v]
is a parametrization of the cyclide of radius k whose focal sets
are the ellipse u->{a*Cos[u],Sqrt[a^2 - c^2]*Sin[u],0} and the
hyperbola v->{c*Sec[v],0,Sqrt[a^2 - c^2]*Tan[v]}."

    ellipsemin::usage="{u,v}->ellipsemin[a,b][t][u,v] is a 1-parameter family
of minimal surfaces such that {u,v}->ellipsemin[a,b][0][u,v]
is an elliptical catenoid and {u,v}->ellipsemin[a,b][Pi/2][u,v]
is an elliptical helicoid. The patch {u,v}->ellipsemin[a,b][0][u,v] contains
the ellipse t->ellipse[a,b][t] as a geodesic."

    ellipsoid::usage="{u,v}->ellipsoid[a,b,c][u,v] is a parametrization of
an ellipsoid with axes of lengths a, b and c. {u,v}->ellipsoid[a,c][u,v]
is a parametrization of an ellipsoid with axes of lengths a, a and c."

    ellipticalhyperboloidplus::usage=
"{u,v}->ellipticalhyperboloidplus[a,b,c][u,v]
is a parametrization of a hyperboloid of one sheet as a ruled surface."

    ellipticalhyperboloidminus::usage=
"{u,v}->ellipticalhyperboloidminus[a,b,c][u,v]
is a parametrization of a hyperboloid of one sheet as a ruled surface."

    ellipticcoor::usage="{u,v,w}->ellipticcoor[d,e,f][a,b,c][w][u,v] is
elliptic coordinate patch on R^3. The parameters d, e and f are
plus 1 or minus 1."

    enneper::usage="{u,v}->enneper[u,v] is a parametrization of
Enneper's minimal surface."

    enneperpolar::usage="{r,theta}->enneperpolar[n][t][r,theta]
is the polar parametrization of a 1-parameter family of minimal surfaces
such that {r,theta}->enneperpolar[n][0][r,theta] is Enneper's minimal surface
of degree n."

    ennepercatenoidpolar::usage="{r,theta}->ennepercatenoidpolar[t][r,theta]
is the polar parametrization of a 1-parameter family of minimal surfaces
constructed from the minimal curve whose Weierstrass representation is given
by f(z)=1 and g(z)=1/z + z^3."

    exptwist::usage="{u,v}->exptwist[a,c][u,v] is a parametrization of a
helicoidial-like surface whose twisting varies exponentially."

    exptwistasymp::usage="{p,q}->exptwistasymp[a,c][p,q] is the parametrization
by asymptotic curves of {p,q}->exptwist[a,c][p,q]."

    flattorus::usage="{u,v}->flattorus[a,b][u,v] is a parametrization of
a torus into R^4 as the product of two circles.
{u,v}->flattorus[a,b,c,d][u,v]} is a parametrization of an elliptical torus
into R^4 as the product of two ellipses. The Gaussian curvature is zero."

    funnel::usage="{u,v}->funnel[1,1,c][u,v] is a parametrization of
the surface of revolution formed by rotating the graph of t->c*Log[t]."

    funnelasym::usage="{p,q}->funnelasym[c][p,q] is the parametrization by
asymptotic curves of the graph of t->c*Log[t]."

    genhypparab::usage="{u,v}->genhypparab[a,b][u,v] is a
parametrization of a hyperbolic paraboloid as a ruled surface."

    handkerchief::usage="{u,v}->handkerchief[a][u,v] is a parametrization of
a handkerchief shaped surface."

    helicoid::usage="{u,v}->helicoid[a,c][u,v] is the
standard parametrization of a circular helicoid
of radius a and slant c.  {u,v}->helicoid[a,b,c][u,v] is
the standard parametrization of an elliptical helicoid of slant c."

    helicoidprin::usage="{u,v}->helicoidprin[a,b][u,v] is a
parametrization of a circular helicoid of radius a and slant c
by principal curves."

    heltocat::usage="{u,v}->heltocat[t][u,v] is a 1-parameter family of
minimal surfaces connecting the helicoid to the catenoid."

    henneberg::usage="{u,v}->henneberg[u,v] is a parametrization of
Henneberg's minimal surface."

    hyperbolicparaboloid::usage="{u,v}->hyperbolicparaboloid[u,v]
is a parametrization of a hyperbolic paraboloid."

    hyperboloid::usage="{u,v}->hyperboloid[a,c][u,v] is the 
standard parametrization of a circular hyperboloid of one sheet.
{u,v}->hyperboloid[a,b,c][u,v] is the standard parametrization of an
elliptical hyperboloid of one sheet."

    hy2sheet::usage="{u,v}->hy2sheet[a,c][u,v] is the
standard parametrization of a circular hyperboloid of two sheets.
{u,v}->hy2sheet[a,b,c][u,v] is the standard parametrization an
elliptical hyperboloid of two sheets."

    kleinbottle::usage="{u,v}->kleinbottle[a][u,v] is a parametrization of
the surface formed by moving and twisting a figure eight along a
circle of radius a."

    klein4::usage="{u,v}->klein4[a,b][u,v] is a parametrization of a
Klein bottle as a surface in R^4."

    kuen::usage="{u,v}->kuen[u,v] is a parametrization of Kuen's surface.
It has constant negative curvature -1."

    kuentcheb::usage="{u,v}->kuentcheb[a][u,v] is a Tchebyshef principal
patch for Kuen's surface of constant negative curvature -a^-2."

    lemniscatemin::usage="{u,v}->lemniscatemin[a][t][u,v] is a
1-parameter family of minimal surfaces such that
{u,v}->lemniscatemin[a][0][u,v] is a minimal surface
containing a lemniscate as a geodesic."

    menn::usage="{u,v}->menn[u,v] is a parametrization of Menn's surface."

    mercatorellipsoid::usage="{u,v}->mercatorellipsoid[a,b,c][u,v]
is is the Mercator injection of an ellipsoid with axes of lengths
a, b and c into R^3."

    moebcirc::usage="{u,v}->moebcirc[a][u,v] is a parametrization of a
Moebius strip that has a circle as boundary."

    moebiusstrip::usage="{u,v}->moebiusstrip[a][u,v] is the
standard parametrization of a Moebius strip."

    monkeysaddle::usage="{u,v}->monkeysaddle[u,v] is a parametrization of
a monkey saddle. {u,v}->monkeysaddle[n][u,v] is a parametrization of a
monkey saddle for a monkey with n-2 tails."

    monkeysaddlepolar::usage="{r,theta}->monkeysaddle[n][r,theta] is a
polar parametrization of a monkey saddle with n-2 tails."

    paraboliccoor::usage="{u,v,w}->paraboliccoor[d,e,f][a,b,c][w][u,v] is
a parabolic coordinate patch on R^3. The parameters d, e and f are
plus 1 or minus 1."

    paraboliccyclide::usage="{u,v}->paraboliccyclide[a,k][u,v]
is a parametrization of the cyclide
of radius k whose focal sets are the parabolas
u->{u,0,-u^2/(8a)+a} and v->{{0,v,v^2/(8a)-a}."

    ellipticparaboloid::usage="{u,v}->ellipticparaboloid[a,b][u,v] is
an elliptic paraboloid."

    paraboloid::usage="{u,v}->paraboloid[a][u,v] is a circular paraboloid of
radius a.  {u,v}->paraboloid[a,b][u,v] and {u,v}->paraboloid[a,b,c][u,v]
are either elliptic or hyperbolic paraboloids."

    perturbedms::usage="{u,v}->perturbedms[a][u,v]  is a parametrization of
a monkey saddle perturbed by a circular paraboloid."

    plane::usage="{u,v}->plane[a1,a2,b1,b2,c1,c2][u,v] is a
parametrization of a plane in R^3."

    plucker::usage="{u,v}->plucker[u,v] is the standard parametrization of
Plucker's surface. {u,v}->plucker[n][u,v] is a parametrization of Plucker's
surface with n folds. {u,v}->plucker[n,m,a][u,v] is a generalization of
the monkeysaddle and Plucker's surface."

    pluckerpolar::usage="{r,theta}->pluckerpolar[n][r,theta] is the
polar parametrization of Plucker's surface with n folds.
{r,theta}->pluckerpolar[m,n,a][r,theta] is a generalization of
the polar parametrizations of the monkeysaddle and Plucker's surface."

    pseudocrosscap::usage="{u,v}->pseudocrosscap[u,v] is a
parametrization of a pseudo cross cap in R^3."

    pseudosphere::usage="{u,v}->pseudosphere[a][u,v] is the
standard parametrization of constant negative curvature -a^-2."

    pstcheb::usage="{u,v}->pstcheb[a][u,v] is a Tchebyshef principal
patch for a pseudosphere of constant negative curvature -a^-2."

    pstchebasym::usage="{p,q}->pstchebasym[a][p,q] is a
Tchebyshef asymptotic patch for a pseudosphere of
constant negative curvature -a^-2."

    rconoid::usage="{u,v}->rconoid[u,v] is a right conoid.  It coincides with
{u,v}->2*pluckerpolar[1][v/2,u]"

    richmond::usage="{u,v}->richmond[u,v] is a minimal surface
with one planar end."

    richmondpolar::usage="{r,theta}->richmondpolar[n][t][r,theta]
is the polar parametrization of a 1-parameter family of minimal surfaces
such that {r,theta}->richmondpolar[n][0][r,theta] is a minimal surface
with one planar end of degree n."

    roman::usage="{u,v}->roman[a][u,v] is Steiner's Roman surface of
radius a."

    rosemin::usage="{u,v}->rosemin[n,a][t][u,v] is a 1-parameter family
of minimal surfaces such that {u,v}->rosemin[n,a][0][u,v] contains the rose
t->{a*Cos[t]*Cos[n*t],a*Cos[n*t]*Sin[t]} as a geodesic."

    scherk::usage="{u,v}->scherk[a][u,v] is a parametrization of
Scherk's minimal surface. {u,v}->scherk[a,theta][u,v] is a parametrization 
of twisted Scherk's minimal surface of angle theta."

     scherk5::usage="{u,v}->scherk5[a,b,c][u,v] is a parametrization of
Scherk's fifth minimal surface, where a, b, c are plus 1 or minus 1."

    shoe::usage="{u,v}->shoe[u,v] is a shoe shaped surface."

    sievert::usage="{u,v}->sievert[a][u,v] is a parametrization of
Sievert's surface of constant positive curvature a^2."

    sphere::usage="{u,v}->sphere[a][u,v] is the standard parametrization of
a sphere of radius a centered at the origin."

    stereographicellipsoid::usage="{u,v}->stereographicellipsoid[a,b,c][u,v]
is a parametrization of a stereographic injection into R^3 of an
ellipsoid with axes of lengths a, b, and c."

    swallowtail::usage="{u,v}->swallowtail[u,v] is a parametrization of
a swallow tail shaped surface."

    tetrahedral::usage="{u,v}->tetrahedral[m,n][A,B,C][a,b,c][u,v] is a
parametrization of tetrahedral surface."

     thomsen::usage="{u,v}->thomsen[a,b][u,v] is a parametrization of
Thomsen's minimal surface."

    torus::usage="{u,v}->torus[a,b][u,v] is a parametrization of
the torus formed by revolving a circle of radius b in the xz-plane
about the z-axis along a circle of radius a in the xy-plane.  
{u,v}->torus[a,b,c][u,v] is the torus formed by revolving
an ellipse with axes of lengths b and c in the xz-plane about the z-axis 
along a circle of radius a in the xy-plane." 

    twiflat::usage="{u,v}->twiflat[pm,a,c][sl][u,v] is a parametrization of
a generalized helicoid of zero Gaussian curvature of slant sl.  The parameter 
pm is plus or minus 1." 

    twisphere::usage="{u,v}->twisphere[a,b][u,v] is a parametrization of
a generalized helicoid formed by rotating and twisting a semicircle.
It is also called a corkscrew surface." 

    wallis::usage="{u,v}->wallis[a,b,c][u,v] is a parametrization of
a conical edge of Wallis."

    whitneyumbrella::usage="{u,v}->whitneyumbrella[u,v] is a Whitney
umbrella."

    wrinkles::usage="{u,v}->wrinkles[a][u,v] is the Monge patch
{u,v}->{u,v,a*(u/v + v/u)}."

Begin["`Private`"]

    astell[a_,b_,c_][u_,v_]:= {a*Cos[u]*Cos[v],
                               b*Sin[u]*Cos[v],c*Sin[v]}^3

    bohdom[a_,b_,c_][u_,v_]:= {a*Cos[u],
                               a*Sin[u] + b*Cos[v],c*Sin[v]}

    bour[u_,v_]:= {(2*u^2 - u^4 - 2*v^2 + 6*u^2*v^2 - v^4)/4, 
                    u*v*(-1 - u^2 + v^2), (2*(u^3 - 3*u*v^2))/3}

    bour[m_][t_][u_,v_]:= Simplify[ComplexExpand[
        analytictominimal[bourmincurve[m]][t][u,v],
        TargetFunctions->{Re,Im}]]

    bourpolar[m_][t_][r_,theta_]:=
      {r^(m - 1)*Cos[t - (m - 1)*theta]/(m - 1) -
       r^(m + 1)*Cos[t - (m + 1)*theta]/(m + 1), 
       r^(m - 1)*Sin[t - (m - 1)*theta]/(m - 1) +
       r^(m + 1)*Sin[t - (m + 1)*theta]/(m + 1), 
       2*r^m*Cos[t - m*theta]/m}

    bourpolar[m_,n_][t_][r_,theta_]:=
      {r^(m - 1)*Cos[t - (m - 1)*theta]/(m - 1) -
       r^(m + 2*n - 1)*Cos[t - (m + 2*n - 1)*theta]/(m + 2*n - 1), 
       r^(m - 1)*Sin[t - (m - 1)*theta]/(m - 1) +
       r^(m + 2*n - 1)*Sin[t - (m + 2*n - 1)*theta]/(m + 2*n - 1), 
       2*r^(m + n - 1)*Cos[t - (m + n - 1)*theta]/(m + n - 1)}

     boy[a_,b_,c_][u_,v_]:=
      {(a*(-Cos[v]^2 + 2*Cos[u]^2*Sin[v]^2 + 
        Cos[v]*Cos[u]*Sin[v]*(-Cos[v]^2 + Cos[u]^2*Sin[v]^2) - 
        Sin[v]^2*Sin[u]^2 + 2*Cos[v]*Sin[v]*Sin[u]*
        (-Cos[v]^2 + Sin[v]^2*Sin[u]^2) - 
        (Sin[v]^4*Sin[4*u])/4))/2, 
       (3^(1/2)*b*(-Cos[v]^2 + 
        Cos[v]*Cos[u]*Sin[v]*(Cos[v]^2 - Cos[u]^2*Sin[v]^2) + 
        Sin[v]^2*Sin[u]^2 - (Sin[v]^4*Sin[4*u])/4))/2,
       c*(Cos[v] + Cos[u]*Sin[v] + Sin[v]*Sin[u])*
        (-4*Sin[v]*(-Cos[v] + Cos[u]*Sin[v])*(Cos[u] - Sin[u])*
        (Cos[v] - Sin[v]*Sin[u]) + 
        (Cos[v] + Cos[u]*Sin[v] + Sin[v]*Sin[u])^3)}

    catalan[a_][u_,v_]:= {a*(u - Sin[u]*Cosh[v]),
                         a*(1 - Cos[u]*Cosh[v]),
                        -4*a*Sin[u/2]*Sinh[v/2]}

    catalandef[a_][t_][u_,v_]:=
        {a*Cos[t]*(u - Cosh[v]*Sin[u]) + 
         a*Sin[t]*(v - Cos[u]*Sinh[v]), 
         a*Cos[t]*(1 - Cos[u]*Cosh[v]) + 
         a*Sin[t]*Sin[u]*Sinh[v], 
         4*a*(1 - Cos[u/2]*Cosh[v/2])*Sin[t] - 
         4*a*Cos[t]*Sin[u/2]*Sinh[v/2]}

    catenoid[c_][u_,v_]:= {c*Cos[u]*Cosh[v/c],
                           c*Sin[u]*Cosh[v/c],v}

    catenoid[a_,b_,c_][u_,v_]:= {a*Cos[u]*Cosh[v],
                                 b*Sin[u]*Cosh[v],c*v}

    catenoidasym[a_][p_,q_]:=
        {a*Cos[(p + q)/2]*Cosh[(q - p)/2], 
         a*Sin[(p + q)/2]*Cosh[(q - p)/2],
         a*(q - p)/2}


    circularcone[a_,b_][u_,v_]:= {a*Sqrt[v^2]*Cos[u],
                                  a*Sqrt[v^2]*Sin[u],b*v}

    circularcylinder[a_][u_,v_]:= {a*Cos[u],a*Sin[u],v}

    clothoidmin[a_][t_][u_,v_]:=
      {a*Pi^(1/2)*Cos[t]*Re[FresnelS[(u + I*v)/Pi^(1/2)]] + 
       a*Pi^(1/2)*Im[FresnelS[(u + I*v)/Pi^(1/2)]]*Sin[t],
       a*Pi^(1/2)*Cos[t]*Re[FresnelC[(u + I*v)/Pi^(1/2)]] + 
       a*Pi^(1/2)*Im[FresnelC[(u + I*v)/Pi^(1/2)]]*Sin[t],
       -(a*v*Cos[t]) + a*u*Sin[t]}

    cnccosurfrev[a_,b_][u_,v_]:= {b*Cos[u]*Sinh[v/a],
                                    b*Sin[u]*Sinh[v/a],
                      -I*Sqrt[a^2 - b^2]*EllipticE[I*v/a,
                      -b^2/(a^2 - b^2)]}

    cnchysurfrev[a_,b_][u_,v_]:= {b*Cos[u]*Cosh[v/a],
                                    b*Sin[u]*Cosh[v/a],
                           - I*a*EllipticE[I*v/a,-b^2/a^2]}

    costa[u_,v_]:=
        {(1/2)Re[-WeierstrassZeta[u + I v,189.07272,0] +
        3.14159 u + 0.35889 +
        0.228473(WeierstrassZeta[u + I v - 1/2,189.07272,0] -
             WeierstrassZeta[u + I v - I/2,189.07272,0])],
        (1/2)Re[-I WeierstrassZeta[u + I v,189.07272,0] +
        3.14159 v + 0.35889 -
        0.228473(I WeierstrassZeta[u + I v - 1/2,189.07272,0] -
             I WeierstrassZeta[u + I v - I/2,189.07272,0])],
        0.626657Log[Abs[(WeierstrassP[u + I v,189.07272,0] -
             6.87519)/
             (WeierstrassP[u + I v,189.07272,0] + 6.87519)]]}

    cpcsurfrev[a_,b_][u_,v_]:= {b*Cos[u]*Cos[v/a],
                                  b*Sin[u]*Cos[v/a],
                                  a*EllipticE[v/a,b^2/a^2]}

    crosscap[a_][u_,v_]:= {a^2*Sin[u]*Sin[2*v]/2,
                 a^2*Sin[2*u]*Cos[v]^2,a^2*Cos[2*u]*Cos[v]^2}

    dini[a_,b_][u_,v_]:= {a*Cos[u]*Sin[v],
                          a*Sin[u]*Sin[v],
                          a*(Cos[v] + Log[Tan[v/2]]) + b*u}
   
    dinitcheb[a_,b_][u_,v_]:=
          {a*Cos[b]*Cos[v]/Cosh[(u - v*Sin[b])/Cos[b]],
           a*Cos[b]*Sin[v]/Cosh[(u - v*Sin[b])/Cos[b]],
           a*(u - Cos[b]*Tanh[(u - v*Sin[b])/Cos[b]])}

    ducyc[{p1_,p2_,p3_},rho_,a_,b_][u_,v_]:=
        {p1 + (rho^2*(-p1 + Cos[u]*(a + b*Cos[v])))/
         ((-p1 + Cos[u]*(a + b*Cos[v]))^2 + 
          (-p2 + (a + b*Cos[v])*Sin[u])^2 + 
          (-p3 + b*Sin[v])^2),
         p2 + (rho^2*(-p2 + (a + b*Cos[v])Sin[u]))/
         ((-p1 + Cos[u]*(a + b*Cos[v]))^2 + 
          (-p2 + (a + b*Cos[v])*Sin[u])^2 + 
          (-p3 + b*Sin[v])^2),
         p3 + (rho^2*(-p3 + b*Sin[v]))/
         ((-p1 + Cos[u]*(a + b*Cos[v]))^2 + 
          (-p2 + (a + b*Cos[v])*Sin[u])^2 + 
         (-p3 + b*Sin[v])^2)}

    ducyc[rho_,a_,b_][u_,v_]:=
        {(rho^2*Cos[u]*(a + b*Cos[v]))/
                (a^2 + b^2 + 2*a*b*Cos[v]),
         (rho^2*(a + b*Cos[v])*Sin[u])/
                (a^2 + b^2 + 2*a*b*Cos[v]),
         (b*rho^2*Sin[v])/
                (a^2 + b^2 + 2*a*b*Cos[v])}

    eighteight[u_,v_]:= {Sin[u]*Sin[v],
                         Cos[u]*Sin[u]*Sin[v],Cos[v]*Sin[v]}

    eightsurface[u_,v_]:=
        {Cos[u]*Sin[2*v],Sin[u]*Sin[2*v],Sin[v]}

    ellhypcyclide[a_,c_,k_][u_,v_]:=
        {(c*(k - c*Cos[u]) + a*Cos[u]*(a - k*Cos[v]))/
                 (a - c*Cos[u]*Cos[v]), 
         ((a^2 - c^2)^(1/2)*(a - k*Cos[v])*Sin[u])/
                 (a - c*Cos[u]*Cos[v]), 
         ((a^2 - c^2)^(1/2)*(k - c*Cos[u])*Sin[v])/
                 (a - c*Cos[u]*Cos[v])}

    ellipsemin[a_,b_][t_][u_,v_]:=
        {a*Cos[t]*Cos[u]*Cosh[v] - a*Sin[t]*Sin[u]*Sinh[v],
         b*Cos[t]*Cosh[v]*Sin[u] + b*Cos[u]*Sin[t]*Sinh[v],
        -(b*(Cos[t]*Im[EllipticE[u + I*v,1 - a^2/b^2]] - 
          Re[EllipticE[u + I*v,1 - a^2/b^2]]*Sin[t]))}

    ellipsoid[a_,c_][u_,v_]:= {a*Cos[v]*Cos[u],
                               a*Cos[v]*Sin[u],c*Sin[v]}
                              
    ellipsoid[a_,b_,c_][u_,v_]:= {a*Cos[v]*Cos[u],
                                  b*Cos[v]*Sin[u],c*Sin[v]}

    ellipticalhyperboloidplus[a_,b_,c_][u_,v_]:=
        {a*Cos[u] - a*v*Sin[u],b*v*Cos[u] + b*Sin[u],c*v}

    ellipticalhyperboloidminus[a_,b_,c_][u_,v_]:=
        {a*Cos[u] + a*v*Sin[u],-b*v*Cos[u] + b*Sin[u],c*v}

    ellipticcoor[d_,e_,f_][a_,b_,c_][w_][u_,v_]:=
         {d*Sqrt[(a - u)*(a - v)*(a - w)/((a - b)*(a - c))],
          e*Sqrt[(b - u)*(b - v)*(b - w)/((b - a)*(b - c))],
          f*Sqrt[(c - u)*(c - v)*(c - w)/((c - a)*(c - b))]}

    enneper[u_,v_]:= {u - u^3/3 + u*v^2,
                     -v + v^3/3 - v*u^2,u^2 - v^2}

    enneper[n_][t_][u_,v_]:= Simplify[ComplexExpand[
        analytictominimal[ennepermincurve[n]][t][u,v],
        TargetFunctions->{Re,Im}]]

    enneperpolar[n_][t_][r_,theta_]:=
        {r*Cos[t - theta] - r^(2*n +1)*
           Cos[t - (2*n +1)*theta]/(2*n +1), 
         r*Sin[t - theta] + r^(2*n +1)*
           Sin[t - (2*n +1)*theta]/(2*n +1), 
         2*r^(n + 1)*Cos[t - (n + 1)*theta]/(n + 1)}

    ennepercatenoidpolar[t_][r_,theta_]:=
        {-r^7*Cos[t - 7*theta]/7 - (2*r^3*Cos[t - 3*theta])/3 +
          r*Cos[t - theta] + Cos[t + theta]/r,
         (r^7*Sin[t - 7*theta])/7 + (2*r^3*Sin[t - 3*theta])/3 +
          r*Sin[t - theta] - Sin[t + theta]/r,
      (r^4*Cos[t - 4*theta])/2 + Cos[t]*Log[r^2] + 2*theta*Sin[t]}

    exptwist[a_,c_][u_,v_]:={a*v*Cos[u],a*v*Sin[u],a*E^(c*u)}

    exptwistasymp[a_,c_][p_,q_]:= {a*E^((c*(p - q))/2)*Cos[p],
                                   a*E^((c*(p - q))/2)*Sin[p],
                                   a*E^(c*p)}

    flattorus[a_,b_][u_,v_]:= {a*Cos[u],a*Sin[u],
                               b*Cos[v],b*Sin[v]}

    flattorus[a_,b_,c_,d_][u_,v_]:= {a*Cos[u],b*Sin[u],
                                     c*Cos[v],d*Sin[v]}

    funnel[a_,b_,c_][u_,v_]:= {a*v*Cos[u],
                               b*v*Sin[u],c*Log[v]}

    funnelasym[c_][p_,q_]:= {c*E^((p - q)/2)*Cos[(p + q)/2],
                            -c*E^((p - q)/2)*Sin[(p + q)/2],
                             c*(p - q)/2}

    genhypparab[a_,b_][u_,v_]:= {a*(u + v),b*v,u^2 + 2*u*v}

    handkerchief[a_][u_,v_]:= {u,v,
                    (1/3)*u^3 + u*v^2 +a*(u^2 - v^2)}

    helicoid[a_,c_][u_,v_]:= {a*v*Cos[u],a*v*Sin[u],c*u}

    helicoid[a_,b_,c_][u_,v_]:= {a*v*Cos[u],b*v*Sin[u],c*u}

    helicoidprin[a_,b_][p_,q_]:=
        {b*Cos[(p + q)/2]*Sinh[(-p + q)/2],
         b*Sin[(p + q)/2]*Sinh[(-p + q)/2],b*(p + q)/2}

    heltocat[t_][u_,v_]:=
        {Cos[u]*Cosh[v]*Sin[t] + Cos[t]*Sin[u]*Sinh[v], 
         Cosh[v]*Sin[t]*Sin[u] - Cos[t]*Cos[u]*Sinh[v], 
         u*Cos[t] + v*Sin[t]}

    henneberg[u_,v_]:=
        {2*Sinh[u]*Cos[v] - (2/3)*Sinh[3*u]*Cos[3*v],
         2*Sinh[u]*Sin[v] + (2/3)*Sinh[3*u]*Sin[3*v],
         2*Cosh[2*u]*Cos[2*v]}

    hyperbolicparaboloid[u_,v_]:= {u,v,u*v}

    hyperbolicparaboloid[a_][u_,v_]:= {u,v,a*u*v}

    hyperboloid[a_,c_][u_,v_]:= {a*Cosh[v]*Cos[u],
                                 a*Cosh[v]*Sin[u],
                                 c*Sinh[v]}

    hyperboloid[a_,b_,c_][u_,v_]:= {a*Cosh[v]*Cos[u],
                                    b*Cosh[v]*Sin[u],
                                    c*Sinh[v]}

    hy2sheet[a_,c_][u_,v_]:= {a*Cosh[u]*Cosh[v],
                              a*Sinh[u]*Cosh[v],
                              c*Sinh[v]}

    hy2sheet[a_,b_,c_][u_,v_]:= {a*Cosh[u]*Cosh[v],
                                 b*Sinh[u]*Cosh[v],
                                 c*Sinh[v]}

    kleinbottle[a_][u_,v_]:=
        {(a + Cos[u/2]*Sin[v] - Sin[u/2]*Sin[2*v])*Cos[u],
         (a + Cos[u/2]*Sin[v] - Sin[u/2]*Sin[2*v])*Sin[u],
          Sin[u/2]*Sin[v] + Cos[u/2]*Sin[2*v]}

    kleinbottle[a_,b_][u_,v_]:=
        {(a + b*(Cos[u/2] Sin[v] - Sin[u/2]*Sin[2 v]))*Cos[u],
         (a + b*(Cos[u/2]*Sin[v] - Sin[u/2]*Sin[2 v]))*Sin[u],
          b*(Sin[u/2]*Sin[v] + Cos[u/2]*Sin[2*v])}

    klein4[a_,b_][u_,v_]:=
        {(a + b*Cos[v])*Cos[u],(a + b*Cos[v])Sin[u],
          b*Sin[v]*Cos[u/2],b*Sin[v]*Sin[u/2]}

    kuen[u_,v_]:=
         {2*(Cos[u] + u*Sin[u])*Sin[v]/(1 + u^2*Sin[v]^2),
          2*(Sin[u] - u*Cos[u])Sin[v]/(1 + u^2*Sin[v]^2),
          Log[Tan[v/2]] + 2*Cos[v]/(1 + u^2*Sin[v]^2)}

    kuentcheb[a_][u_,v_]:=
          {a*(2*Cosh[v]*(Cos[u] + u*Sin[u]))/(Cosh[v]^2 + u^2), 
           a*(2*Cosh[v]*(-u*Cos[u] + Sin[u]))/(Cosh[v]^2 + u^2), 
            a*(v - (2*Sinh[v]*Cosh[v])/(Cosh[v]^2 + u^2))}

    lemniscatemin[a_][t_][u_,v_]:=
        {(-16*a*Cos[u]*Cosh[v]*Sin[u]*Sinh[v]*
         (Cos[u]*Cosh[v]*Sin[t] + Cos[t]*Sin[u]*Sinh[v]))/
         (18 + Cos[4*u] - 12*Cos[2*u]*Cosh[2*v] + Cosh[4*v]) +
         (4*a*(3 - Cos[2*u]*Cosh[2*v])*
         (Cos[t]*Cos[u]*Cosh[v] - Sin[t]*Sin[u]*Sinh[v]))/
         (18 + Cos[4*u] - 12*Cos[2*u]*Cosh[2*v] + Cosh[4*v]), 
         (a*(-Sin[t - 4*u] + 6*Cosh[2*v]*Sin[t - 2*u] - 
          6*Cosh[2*v]*Sin[t + 2*u] + Sin[t + 4*u] - 
          6*Sin[t - 2*u]*Sinh[2*v] -  6*Sin[t + 2*u]*Sinh[2*v] +
          2*Sin[t]*Sinh[4*v]))/(2*(-18 - Cos[4*u] +
          12*Cos[2*u]*Cosh[2*v] - Cosh[4*v])),
          a*(-(Cos[t]*Im[EllipticF[u + I*v, -1]]) + 
          Re[EllipticF[u + I*v, -1]]*Sin[t])}

    menn[a_][u_,v_]:= {u,v,a*u^4 + u^2*v - v^2}

    mercatorellipsoid[a_,b_,c_][u_,v_]:=
        {a*Sech[v]*Cos[u],b*Sech[v]Sin[u],c*Tanh[v]}

    moebcirc[a_][u_,v_]:={a*(-2*Cos[2*v]*Sin[u])/
     (-2 + 2^(1/2)*Cos[u]*Sin[v] + 2^(1/2)*Sin[u]*Sin[2*v]),
      a*(2^(1/2)*(Cos[u]*Sin[v] - Sin[u]*Sin[2*v]))/
     (-2 + 2^(1/2)*Cos[u]*Sin[v] + 2^(1/2)*Sin[u]*Sin[2*v]),
       a*(-2*Cos[u]*Cos[v])/
     (-2 + 2^(1/2)*Cos[u]*Sin[v] + 2^(1/2)*Sin[u]*Sin[2*v])}

    moebiusstrip[a_][u_,v_]:= {a*(Cos[u] + v*Cos[u/2]*Cos[u]),
        a*(Sin[u] + v*Cos[u/2]*Sin[u]),a*v*Sin[u/2]}

    monkeysaddle[u_,v_]:= {u,v,u^3 - 3*u*v^2}

    monkeysaddle[n_][u_,v_]:={u,v,
        Simplify[ComplexExpand[Re[(u+I*v)^n],
           TargetFunctions->{Re,Im}]]}

    monkeysaddlepolar[n_][r_,theta_]:=
        {r*Cos[theta],r*Sin[theta],r^n*Sin[n*theta]}

    paraboliccoor[d_,e_,f_][a_,b_,c_][w_][u_,v_]:=
         {d*Sqrt[(a - u)*(a - v)*(a - w)/(b - a)],
          e*Sqrt[(b - u)*(b - v)*(b - w)/(a - b)],
          f*(c - a - b + u + v + w)/2}

    ellipticparaboloid[a_,b_][u_,v_]:=
                       {u,v,u^2/a^2 + v^2/b^2}

    paraboloid[a_][u_,v_]:= {u,v,a*(u^2 + v^2)}

    paraboloid[a_,b_][u_,v_]:= {u,v,a*u^2 + b*v^2}

    paraboloid[a_,b_,c_][u_,v_]:= {u,v,a*u^2 + b*v^2 + c*u*v}

    paraboliccyclide[a_,k_][u_,v_]:=
        {(u*(8*a^2 + k + v^2))/(16*a^2 + u^2 + v^2), 
        ((8*a^2 - k + u^2)*v)/(16*a^2 + u^2 + v^2), 
        (16*a^2*k - 16*a^2*u^2 - k*u^2 + 16*a^2*v^2 - k*v^2)/
        (8*a*(16*a^2 + u^2 + v^2))}

    perturbedms[a_][u_,v_]:=
            {u,v,(1/3)*u^3 - u*v^2 + a*(u^2 + v^2)}

    plane[a1_,a2_,b1_,b2_,c1_,c2_][u_,v_]:=
        {a1*u + a2*v,b1*u + b2*v,c1*u + c2*v}

    plucker[u_,v_]:= {u,v,2*u*v/(u^2 + v^2)}
    
    plucker[n_][u_,v_]:= {u,v,
        Simplify[ComplexExpand[Re[(u + I*v)^n]/Abs[(u + I*v)^n],
           TargetFunctions->{Re,Im}]]}

    plucker[n_,m_,a_][u_,v_]:= {a*u,a*v,
        Simplify[ComplexExpand[Re[a*(u + I*v)^n]/Abs[(u + I*v)^(n - m)],
           TargetFunctions->{Re,Im}]]}

    pluckerpolar[n_][r_,theta_]:=
                    {r*Cos[theta],r*Sin[theta],Sin[n*theta]}

    pluckerpolar[m_,n_,a_][r_,theta_]:=
        {a*r*Cos[theta],a*r*Sin[theta],a*r^m*Sin[n*theta]}

    pseudocrosscap[u_,v_]:=  
                 {(1 - u^2)*Sin[v],(1 - u^2)*Sin[2*v],u}

    pseudosphere[a_][u_,v_]:= {a*Cos[u]*Sin[v],
                               a*Sin[u]*Sin[v],
                               a*(Cos[v] + Log[Tan[v/2]])}

    pstcheb[a_][u_,v_]:= {a*Cos[v]/Cosh[u],
                          a*Sin[v]/Cosh[u],
                          a*(u - Tanh[u])}

    pstchebasym[a_][p_,q_]:= {a*Cos[(p - q)/2]*Sech[(p + q)/2],
                              a*Sech[(p + q)/2]*Sin[(p - q)/2], 
                              a*((p + q)/2 - Tanh[(p + q)/2])}

    rconoid[u_,v_]:= {v*Cos[u],v*Sin[u],2*Sin[u]}

    richmond[u_,v_]:=
        {(-3*u - u^5 + 2*u^3*v^2 + 3*u*v^4)/(6*(u^2 + v^2)),
         (-3*v - 3*u^4*v - 2*u^2*v^3 + v^5)/(6*(u^2 + v^2)),u}

    richmond[n_][t_][u_,v_]:=Simplify[ComplexExpand[
        analytictominimal[richmondmincurve[n]][t][u,v],
        TargetFunctions->{Re,Im}]]

    richmondpolar[n_][t_][r_,theta_]:=
        {-Cos[t + theta]/(2*r) - 
          r^(2*n + 1)*Cos[t - (2*n + 1)*theta]/(4*n + 2),
         -Sin[t + theta]/(2*r) + 
          r^(2*n + 1)*Sin[t - (2*n + 1)*theta]/(4*n + 2),
          r^n*Cos[t - n*theta]/n}

    roman[a_][u_,v_]:= {(a^2/2)*Sin[2*u]Cos[v]^2,
                        (a^2/2)*Sin[u]*Sin[2*v],
                        (a^2/2)*Cos[u]*Sin[2*v]}

    roman[n_,a_][u_,v_]:= {(a^2/2)*(Cos[u]*Cos[v]^2*Sin[u])^n,
                           (a^2/2)*(Cos[v]*Sin[u]*Sin[v])^n,
                           (a^2/2)*(Cos[u]*Cos[v]*Sin[v])^n}

    rosemin[n_,a_][t_][u_,v_]:=
    {Cos[n*u]*Cosh[n*v]*(a*Cos[t]*Cos[u]*Cosh[v] - 
       a*Sin[t]*Sin[u]*Sinh[v]) + 
        Sin[n*u]*(-(a*Cos[u]*Cosh[v]*Sin[t]) - 
       a*Cos[t]*Sin[u]*Sinh[v])*Sinh[n*v], 
       -(Cos[u]*Sinh[v]*(-(a*Cos[n*u]*Cosh[n*v]*Sin[t]) - 
         a*Cos[t]*Sin[n*u]*Sinh[n*v])) + 
        Cosh[v]*Sin[u]*(a*Cos[t]*Cos[n*u]*Cosh[n*v] - 
       a*Sin[t]*Sin[n*u]*Sinh[n*v]), 
       -((a*Cos[t]*Im[EllipticE[n*(u + I*v), 1 - n^2]])/n) + 
        (a*Re[EllipticE[n*(u + I*v), 1 - n^2]]*Sin[t])/n}

    scherk[a_][u_,v_]:= {u,v,(1/a)*Log[Cos[a*v]/Cos[a*u]]}

    scherk[a_,theta_][u_,v_]:=
        {Sec[2*theta]*(Cos[theta]*u + Sin[theta]*v),
         Sec[2*theta]*(Sin[theta]*u + Cos[theta]*v),
         (1/a)*Log[
         Cos[a*Sec[2*theta]*(Sin[theta]*u + Cos[theta]*v)]/
         Cos[a*Sec[2*theta]*(Cos[theta]*u + Sin[theta]*v)]]}
   
    scherk5[u_,v_]:= {ArcSinh[u],ArcSinh[v],ArcSin[u*v]}

    scherk5[a_,b_,c_][u_,v_]:= {a*ArcSinh[u],
                                b*ArcSinh[v],
                                c*ArcSin[u*v]}

    shoe[u_,v_]:= {u,v,(1/3)*u^3 - (1/2)*v^2} 

    sievert[a_][u_,v_]:=
       {2/(a + 1 - a*Sin[v]^2*Cos[u]^2)*
        (Sqrt[(a + 1)*(1 + a*Sin[u]^2)]*Sin[v]/Sqrt[a])*
         Cos[-u/Sqrt[a + 1] + ArcTan[Sqrt[a + 1]*Tan[u]]],
         2/(a + 1 - a*Sin[v]^2*Cos[u]^2)*
         (Sqrt[(a + 1)*(1 + a*Sin[u]^2)]*Sin[v]/Sqrt[a])*
         Sin[-u/Sqrt[a + 1] + ArcTan[Sqrt[a + 1]*Tan[u]]],
         (Log[Tan[v/2]] +
         2*(a + 1)/(a + 1 - a*Sin[v]^2*Cos[u]^2)*
         Cos[v])/Sqrt[a]}

    sphere[a_][u_,v_]:= {a*Cos[v]*Cos[u],a*Cos[v]*Sin[u],a*Sin[v]}

    stereographicellipsoid[a_,b_,c_][u_,v_]:=
        {2*a*u/(1 + u^2 + v^2),2*b*v/(1 + u^2 + v^2),
         (c*(-1 + u^2 + v^2))/(1 + u^2 + v^2)}

    swallowtail[u_,v_]:={3*v^4 + u*v^2,-4*v^3 - 2*u*v,u}

    tetrahedral[m_,n_][A_,B_,C_][a_,b_,c_][u_,v_]:=
              {A*(u - a)^m*(v - a)^n,
               B*(u - b)^m*(v - b)^n,
               C*(u - c)^m*(v-c)^n}

    thomsen[a_,b_][u_,v_]:=
        {b*u/a + Sqrt[1+b^2]*Sinh[a*u]*Cos[a*v]/a^2,
        Sqrt[1 + b^2]*v/a + b*Cosh[a*u]*Sin[a*v]/a^2,
        Sinh[a*u]*Sin[a*v]/a^2}

    torus[a_,b_][u_,v_]:= {(a + b*Cos[v])*Cos[u],
                           (a + b*Cos[v])*Sin[u],
                            b*Sin[v]}

    torus[a_,b_,c_][u_,v_]:= {(a + b*Cos[v])*Cos[u],
                              (a + b*Cos[v])*Sin[u],
                               c*Sin[v]}

    torus[a_,b_,c_,d_][u_,v_]:=
        {(a + b*Cos[v])*Cos[u],(d + b*Cos[v])*Sin[u],c*Sin[v]}

    torus[a_,b_,c_,d_,e_][u_,v_]:=
        {(a  +b*Cos[v])*Cos[u],(d + e*Cos[v])*Sin[u],c*Sin[v]}

    twiflat[pm_,a_,c_][sl_][u_,v_]:= {v*Cos[u],v*Sin[u],
        sl*u + ArcSin[c/(v*a)]*c + (v^2*a^2 - c^2)^(1/2)*pm}

    twisphere[a_,b_][u_,v_]:= {a*Cos[u]*Cos[v],
                               a*Sin[u]*Cos[v],
                               a*Sin[v] + b*u}

    allis[a_,b_,c_][u_,v_]:= {v*Cos[u],v*Sin[u],
                               c*Sqrt[a^2 - b^2*Cos[u]^2]}
 
    whitneyumbrella[u_,v_]:= {u*v,u,v^2}

    wrinkles[a_][u_,v_]:= {u,v,a*(u/v + v/u)}
End[]

EndPackage[]
