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

(* Be patient, this may take a while to run. The sphere at the origin was added to ensure that Shapeways will print this model *)

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

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)  };

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

zmin=-1;
zmax=1;

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

xmin=-rmax;
xmax=rmax;

NumConstantRadiusCurves=3;
NumRays=24;

numPoints=50;

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

OuterCurveTable=Table[SurfacePolarPar[r,theta],{r,rmin,rmax,(rmax-rmin)/NumConstantRadiusCurves}];

RaysTable=Table[SurfacePolarPar[r,j],{j,thetamin,thetamax,(thetamax-thetamin)/NumRays}];

OuterCurve=ParametricPlot3D[OuterCurveTable,{theta,thetamin,thetamax},PlotStyle->Tube[radius],MaxRecursion->5,PlotPoints->numPoints,PlotRange->All];

Rays=ParametricPlot3D[RaysTable,{r,rminRays,rmax},PlotStyle->Tube[radius],MaxRecursion->5,PlotPoints->numPoints,PlotRange->All];
 

Origin =Graphics3D[Sphere[{0,0,0},3*radius]];

output=Show[HorizontalAxisCurve, OuterCurve,Rays,Origin]

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