Mathematica Asked on May 24, 2021
My searches have lead nowhere on this one.
I have a MeshRegion
(say, a 2D manifold embedded in 3D) and would like to plot a function on it: such that the color of a point at (x,y,z) is determined by a function of the coordinates.
I have found MeshCellStyle
, which allows me to specify flat color per cell, but does give access to coordinates for a full ColorFunction
-style. There’s also RegionPlot3D
, which might work (using (x,y,z) ∈ ℛ
) for a full-dimensional submanifold but when passed a lower-dimensional object embedded in 3D the sampling algorithm never hits.
You can extract mesh coordinates and polygons of your MeshRegion
and use them to construct a GraphicsComplex
with VertexColors
.
For example:
mreg = DiscretizeRegion[
ImplicitRegion[-3 y - 4 x y^2 + 4 x z^2 + 4 x^2 z + 2 y^2 z^2 + z^3 == 0,
{x, y, z}], MaxCellMeasure -> .001]
mc = MeshCoordinates[mreg];
polys = MeshCells[mreg, 2];
f[x_, y_, z_] := x y + z;
Graphics3D[{EdgeForm[],
GraphicsComplex[mc, polys, VertexColors -> (Hue[f@##] & @@@ Rescale[mc])]},
Boxed -> False]
Use VertexColors -> (Opacity[.7, Hue[f@##]] & @@@ Rescale[mc])
to get
Correct answer by kglr on May 24, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP