I want to draw a set of convex polyhedrons whose vertices are defined by spherical coordinates on the surface of a unit sphere.
Currently I followed the advice from here: https://mathematica.stackexchange.com/a/21842/651 But it draws diagonals on any tetragonal face. Each face is composed of triangles. Is it possible to accomplish the same but without tetragonal faces diagonaled?
The current code:
Needs["TetGenLink`"]
mapping[{1,0,0}]={0,0,1}
mapping[{1,Pi,0}]={0,0,-1}
mapping:=CoordinateTransformData[{"Spherical"->"Cartesian"},"Mapping"]
verteces[n_]:=Flatten[Table [{1,Pi k/n, i 2Pi/Binomial[n,k]},{k,0,n},{i,0,Binomial[n,k]-1}],1]
Convex[n_]:=TetGenConvexHull[mapping/@ verteces[n]]
pts[n_]:=First[Convex[n]]
surface[n_] :=Last[Convex[n]]
b:=5
Graphics3D[{Yellow,Opacity[.9],GraphicsComplex[pts[b],Polygon[surface[b]]], Black, Line[{{0,0,-1.1},{0,0,1.1}}]}]
Answer
<< ComputationalGeometry`
ComputationalGeometry`Methods`ConvexHull3D[mapping /@ verteces[5],
Axes -> None, Graphics`Mesh`FlatFaces -> False]
Mapping over n (well, with a trick because it fails with more than three calculations in a row):
Edit
merging with your code:
<< ComputationalGeometry`
mapping[{1, 0, 0}] = {0, 0, 1}
mapping[{1, Pi, 0}] = {0, 0, -1}
mapping := CoordinateTransformData[{"Spherical" -> "Cartesian"}, "Mapping"]
verteces[n_] := Flatten[Table[{1, Pi k/n, i 2 Pi/Binomial[n,k]}, {k,0,n}, {i, 0,Binomial[n,k]-1}], 1]
Graphics3D[{Yellow, Opacity[.9],
Sequence @@ ComputationalGeometry`Methods`ConvexHull3D[mapping /@ verteces[5],
Axes -> None, Graphics`Mesh`FlatFaces -> False],Black,Line[{{0, 0, -1.1}, {0, 0, 1.1}}]}]
Comments
Post a Comment