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

fPos[u_,v_]:={u,v,(u^2+v^2-1)^0.5};
fNeg[u_,v_]:={u,v,-(u^2+v^2-1)^0.5};

LevelCirclePos[u_,v_] := {v*Cos[u],v*Sin[u],(v^2-1)^0.5}
LevelCircleNeg[u_,v_] := {v*Cos[u],v*Sin[u],-(v^2-1)^0.5}

scale = 8;
radius = 1;
numPoints=100;
gridsteps=8;

MaxRadius=4;

umin=-MaxRadius;
umax=MaxRadius;
vmin=-MaxRadius;
vmax=MaxRadius;

curvesUPos=Table[scale*fPos[u,i],{i,vmin,vmax,(vmax-vmin)/gridsteps}];
curvesVPos=Table[scale*fPos[j,v],{j,umin,umax,(umax-umin)/gridsteps}];
curvesUNeg=Table[scale*fNeg[u,i],{i,vmin,vmax,(vmax-vmin)/gridsteps}];
curvesVNeg=Table[scale*fNeg[j,v],{j,umin,umax,(umax-umin)/gridsteps}];

curvesLevelCirclesPos = Table[scale*LevelCirclePos[u,i],{i,{1,MaxRadius}}];

curvesLevelCirclesNeg = Table[scale*LevelCircleNeg[u,i],{i,{1,MaxRadius}}];


tubesUPos=ParametricPlot3D[curvesUPos,{u,umin,umax},
RegionFunction->Function[{x,y,z}, (scale*1)^2 ≤ x^2+y^2 ≤ (scale*MaxRadius)^2],
PlotStyle->Tube[radius],PlotPoints->numPoints,PlotRange->All];

tubesVPos=ParametricPlot3D[curvesVPos,{v,vmin,vmax},RegionFunction->Function[{x,y,z}, (scale*1)^2 ≤ x^2+y^2 ≤  (scale*MaxRadius)^2],PlotStyle->Tube[radius],PlotPoints->numPoints,PlotRange->All];

tubesUNeg=ParametricPlot3D[curvesUNeg,{u,umin,umax},
RegionFunction->Function[{x,y,z}, (scale*1)^2 ≤ x^2+y^2 ≤ (scale*MaxRadius)^2],PlotStyle->Tube[radius],PlotPoints->numPoints,PlotRange->All];

tubesVNeg=ParametricPlot3D[curvesVNeg,{v,vmin,vmax},RegionFunction->Function[{x,y,z}, (scale*1)^2 ≤ x^2+y^2 ≤  (scale*MaxRadius)^2],PlotStyle->Tube[radius],PlotPoints->numPoints,PlotRange->All];

tubesLevelCirclesPos =ParametricPlot3D[curvesLevelCirclesPos,{u,0,2*Pi+1},PlotStyle->Tube[radius],PlotPoints->numPoints,PlotRange->All];

tubesLevelCirclesNeg =ParametricPlot3D[curvesLevelCirclesNeg,{u,0,2*Pi+1},PlotStyle->Tube[radius],PlotPoints->numPoints,PlotRange->All];

output=Show[tubesUPos,tubesVPos,tubesUNeg,tubesVNeg,tubesLevelCirclesPos,tubesLevelCirclesNeg]

(*Export["HyperboloidOneSheetRectangularGridCurves.stl",output];*)