How to draw a triangulated sphere such as the one below in Mathematica, without being restricted to these colors, but with a more uniform color (possibly with some shaded area), and with the background frame removed?
Answer
If you're a) on 10+ and b) don't need this cells to truly be colored, you can try this:
mesh = DiscretizeRegion@Sphere[];
MeshRegion[mesh,
Lighting -> Sequence @@@ {
ConstantArray[{"Point", Red, {0, 0, 75}}, 2],
Map[{"Point", Yellow, Append[#, 0]} &,
CirclePoints[3., 6]
],
ConstantArray[{"Point", Blue, {0, 0, -75}}, 2]
},
MeshCellHighlight -> {{1, All} -> Black}
]
This is just tricking you into thinking it's colored using Lighting
. I was too lazy to highlight each cell. It's possible to write code to color an arbitrary discretized surface at the cell level. I've done it, but it's more code than I want to post here and isn't thoroughly proof-read. If you need that I can dig it up from wherever it's hiding, though.
Update
OP mentions in the comments that he's really interested in the triangulation. That's easily extracted as such:
triangulation =
With[{cds = MeshCoordinates@mesh},
MeshCells[mesh, 2] /. i_Integer :> cds[[i]]
];
And just to check that we pulled it out right:
triangulation // Graphics3D
Comments
Post a Comment