stereographic projection illustration 2

2006-08
   Xah
   xah@xahlee.org
 ∑ http://xahlee.org/

init

The following packages can be found on http://xahlee.org/

Needs["Transform2DPlot`"]

et

?RectangularGrid

Show[floorGraphics2D=(IncreaseGraphicsResolution[#1,20]&)[Graphics[RectangularGrid[{-2,2,.2},{-2,2,.2}]]],Frame->True,AspectRatio->Automatic,PlotRange->All,Thickness->0.8]

patchGraphics2D=Graphics@{{Hue@.25,Polygon[({1,1}*3/5+#&)/@({{0,0},{1,0},{1,1},{0,1}}/5)]},{Hue@0,Polygon[({(3/5),(1/5)}+#&)/@({{0,0},{1,0},{1,1},{0,1}}/5)]},
{Hue@.75,Polygon[({(3/5),-(1/5)}+#&)/@({{0,0},{1,0},{1,1},{0,1}}/5)]}}

Show[{floorGraphics2D,patchGraphics2D},Frame->True,AspectRatio->Automatic,PlotRange->All,Axes->True]

floorGraphics3D=Graphics3D@@floorGraphics2D/.{li_Line:>Map[Append[#,0]&,li,{2}],poly_Polygon:>Map[Append[#,0]&,poly,{2}]}

patchGraphics3D=Graphics3D@@patchGraphics2D/.{li_Line:>Map[Append[#,0]&,li,{2}],poly_Polygon:>Map[Append[#,0]&,poly,{2}]}

Show[{floorGraphics3D,patchGraphics3D},Boxed->True,AspectRatio->Automatic,Axes->True]

raysGraphics3D=patchGraphics3D/.Polygon[pts_]:>(Line[{{0,0,1},#}]&)/@pts

ballGraphics3D=Graphics3D[First[StereographicProjectionPlot3D[Graphics[Sequence@@floorGraphics2D,Sequence@@patchGraphics2D],Frame->True,AspectRatio->Automatic,PlotRange->All,AdaptiveSampling->True,ResolutionLength->.07]]]

Show[{floorGraphics3D,raysGraphics3D,patchGraphics3D,ballGraphics3D},Boxed->True,AspectRatio->Automatic,PlotRange->{{-0.7`,1.5`},{-0.7`,1.5`},{0,1}},Axes->True]

JavaView

Export graphics to file for JavaView

graData=(Sequence@@#&)/@{floorGraphics3D,raysGraphics3D,patchGraphics3D,ballGraphics3D};
eP=3;
tt=OpenWrite["x.mgs"];
WriteString[tt,"Graphics3D["];
WriteString[tt,(StringReplace[#,", "->","]&)@ToString@NumberForm[SetPrecision[Chop[graData,10^-(eP+1)],eP],ExponentFunction->(If[-∞<#1<∞,Null,#1]&)]];
WriteString[tt,",Lighting->False]"];
Close@tt;