(* Enneper's Surface (c) 1990 Stewart Dickson
   From: David Hoffman, "The Computer-Aided Discovery of New Embedded
         Minimal Surfaces", The Mathematical Intelligencer, Volume 9,
         Number 3, 1987 *)
(* The Global Enneper-Weierstrass representation of minimal surfaces *)
(* X := Re[Integrate[phi, {z, p0, p}]]; p = {u + I v} *)
Clear[phi]
Clear[X]
Clear[r]
Clear[th]
phi[f_, g_, eta_] := {(1 - g ^2)f, I (1 + g ^ 2) f, 2 f g} eta
X[z0_, f_, g_, eta_]:= 
X[z0,  f, g, eta] = Re[Integrate[phi[f, g, eta], {z, z0, Z}]] /. Z->r Exp[I th]
Xeval = X[0, 1, z, 1]

MakePolygons[vl_List] :=
    Block[{l = vl,
           l1 = Map[RotateLeft, vl],
           mesh},
        mesh = {l, RotateLeft[l], RotateLeft[l1], l1};
        mesh = Map[Drop[#, -1]&, mesh, {1}];
        mesh = Map[Drop[#, -1]&, mesh, {2}];
        Polygon /@ Transpose[ Map[Flatten[#, 1]&, mesh] ]
    ]

centerview = {-0.4663000000000001, -2.8304, 1.7947};

enneperpolys = MakePolygons[Table[Xeval, {th, 0, 2 Pi, Pi/50},
	{r, 0, 3.0, 1 / 10}]];

VecLen[{x_, y_, z_}] := Sqrt[N[x ^2 + y ^2 + z ^2]];
Cross[u_List, v_List] := Det[{{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, u, v}];

centerline = {0.0, 0.0, -1.0};
eyeline = Cross[centerline, centerview];
ueyeline = eyeline / VecLen[eyeline];
viewdist = VecLen[centerview];
eyedist = viewdist / 24;
leftview = centerview + eyedist * ueyeline;
rightview = centerview - eyedist * ueyeline;
leftplot = Graphics3D[enneperpolys, ViewPoint -> leftview, Boxed->False,
	AspectRatio->.47,
	Background->RGBColor[0, 0, 0], RenderAll->False, LightSources -> 
	{{{0.7071, 0, 0.7071}, RGBColor[0.9481, 0, 0]}, 
 	{{0.5773, 0.5773, 0.5773}, RGBColor[0, 0.8888, 0]}, 
 	{{0, 0.7071, 0.7071}, RGBColor[0, 0, 1]}}
	]
Display["enneper2_left.ps", leftplot];
Clear[leftplot];

rightplot = Graphics3D[enneperpolys, ViewPoint -> rightview, Boxed->False,
	AspectRatio->.47,
	Background->RGBColor[0, 0, 0], RenderAll->False, LightSources -> 
	{{{0.7071, 0, 0.7071}, RGBColor[0.9481, 0, 0]}, 
 	{{0.5773, 0.5773, 0.5773}, RGBColor[0, 0.8888, 0]}, 
 	{{0, 0.7071, 0.7071}, RGBColor[0, 0, 1]}}
	]
Display["enneper2_right.ps", rightplot]
