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

(* A cool thing to do with this model would be to add the second ruling,   which you can discover for yourself using symmetry considerations. Apart from anything else, as it stands this model tends to bend due to the lack of symmetry of internal strains *)

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

Ruling[t_,v_] := {Cos[t] - v*Sin[t], Sin[t]+v*Cos[t],v}

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

MaxRadius=4;

MaxHeight= (MaxRadius^2 - 1)^0.5;

NumLevelCurves = 3;
NumRulings=16;

tmin=0;
tmax=2*Pi;  
umin=0;
umax=2*Pi; 

curvesLevelCircles = Table[scale*LevelCircle[u,j],{j,-MaxHeight,MaxHeight, 2*MaxHeight/(NumLevelCurves-1)}];

curvesRuling = Table[scale*Ruling[i,v],{i,tmin,tmax,(tmax-tmin)/(NumRulings)}];

tubesLevelCircles =ParametricPlot3D[curvesLevelCircles,{u,umin,umax+1},PlotStyle->Tube[radius],PlotPoints->numPoints,PlotRange->All];

tubesRuling =ParametricPlot3D[curvesRuling,{v,-MaxHeight,MaxHeight},PlotStyle->Tube[radius],PlotPoints->numPoints,PlotRange->All];


output=Show[tubesLevelCircles,tubesRuling]

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