(*This Mathematica code was written by John Zweck (zweck@utdallas.edu) and generates a mathematical curve/surface that can be printed using a 3D printer. This model can (probably) be printed by Shapeways.*)

(*If you evaluate this Mathematica notebook,the curve/surface will be rendered using computer graphics.*)

(*If you uncomment the export line at the end of the code and set the directory path appropriately for your system you will obtain an STL file that can be sent to a 3D printer.*)

(*The STL file can also be viewed using the open source software Meshlab.*)

(*You may modify this code in any way you like.*)

(*This project was supported by the National Science Foundation through a Supplement to the UTeach Dallas Robert Noyce Scholarship Program (DUE 1544159).*)

(* My recollection is that this model did not pass Shapeways automatic tests *)

xyscale=10;
zscale=50;
radius = 2;

SurfacePosSqrt[u_,v_]={xyscale*u,xyscale*u^2*Piecewise[{{(1+(1-v^2)^.5)/v,v<0},{(1+(1-v^2)^.5)/v,v>0}}],zscale*v};

SurfaceNegSqrt[u_,v_]={xyscale*u,xyscale*u^2*Piecewise[{{(1-(1-v^2)^.5)/v,v<0},{(1-(1-v^2)^.5)/v,v>0}}],zscale*v};

SurfacePolarPar[r_,theta_] = {xyscale*r*Cos[theta],xyscale*r*Sin[theta],zscale*2*r*Cos[theta]^2*Sin[theta]/(r^2*Cos[theta]^4 + Sin[theta]^2)  };

VerticalAxis[t_]={0,0,zscale*t};

HorizontalAxis[y_]={0,xyscale*y,0};

zmin=-1;
zmax=1;

rmin=0;
rmax=5;
thetamin=0;
thetamax=2*Pi;

xmin=-rmax;
xmax=rmax;

NumParabolas=8;

numPoints=500;


VerticalAxisCurve=ParametricPlot3D[VerticalAxis[z],{z,zmin,zmax},PlotStyle->Tube[radius],PlotStyle->CapForm["Round"],PlotStyle->JoinForm["Round"],PlotPoints->numPoints,PlotRange->All];

HorizontalAxisCurve=ParametricPlot3D[HorizontalAxis[y],{y,-rmax,rmax},PlotStyle->Tube[radius],PlotStyle->CapForm["Round"],PlotStyle->JoinForm["Round"],PlotPoints->numPoints,PlotRange->All];

OuterCurveTable=Table[SurfacePolarPar[r,theta],{r,rmax,rmax,1}];

OuterCurve=ParametricPlot3D[OuterCurveTable,{theta,thetamin,thetamax},PlotStyle->Tube[radius],PlotStyle->CapForm["Round"],PlotStyle->JoinForm["Round"],MaxRecursion->15,PlotPoints->numPoints,PlotRange->All];

InnerCurvesTable=Table[SurfacePolarPar[r,theta],{r,rmax/3,2*rmax/3,rmax/3}];

InnerCurves=ParametricPlot3D[InnerCurvesTable,{theta,thetamin,thetamax},PlotStyle->Tube[radius],PlotStyle->CapForm["Round"],PlotStyle->JoinForm["Round"],MaxRecursion->15,PlotPoints->numPoints,PlotRange->All];

ParabolasPosSqrtTable=Table[SurfacePosSqrt[x,j],{j,zmin,zmax,(zmax-zmin)/NumParabolas}];

ParabolasPosSqrt=ParametricPlot3D[ParabolasPosSqrtTable,{x,xmin,xmax},
RegionFunction->Function[{x,y,z},(x^2+y^2)^0.5<xyscale*rmax],
PlotRange->All,PlotStyle->CapForm["Round"],PlotStyle->JoinForm["Round"],
MaxRecursion->15,PlotPoints-> numPoints,Axes->None]/.Line[pts_,rest___]:>Tube[pts,radius,rest];

ParabolasNegSqrtTable=Table[SurfaceNegSqrt[x,j],{j,zmin,zmax,(zmax-zmin)/NumParabolas}];

ParabolasNegSqrt=ParametricPlot3D[ParabolasNegSqrtTable,{x,xmin,xmax},
RegionFunction->Function[{x,y,z},(x^2+y^2)^0.5<xyscale*rmax],
PlotRange->All,PlotStyle->CapForm["Round"],PlotStyle->JoinForm["Round"],
MaxRecursion->15,PlotPoints-> numPoints,Axes->None]/.Line[pts_,rest___]:>Tube[pts,radius,rest];
 
SurfaceSheet=ParametricPlot3D[{SurfacePolarPar[r,theta]},{r,rmin,rmax },{theta,thetamin,thetamax+0.2},Mesh->False, MaxRecursion->8, PlotStyle->{Thickness[2.0]}];

output=Show[SurfaceSheet,VerticalAxisCurve,HorizontalAxisCurve, OuterCurve, ParabolasPosSqrt,ParabolasNegSqrt]

(* Export["LimitDNEViaParabolasSheet.stl",output] *)