1
$\begingroup$

I have a Graphics3D element and want to calculate its RegionCentroid. However, a graph is not considered a proper region by Mathematica. How can I convert my graph (which has tubes or cylinders as edges) into a region in order to be able to treat it like a 3-D object rather than a graph?

$\endgroup$
4
$\begingroup$

One way is to convert to a 3D graphics, then to a region:

graph = ParametricPlot3D[{x, y, (x + y)^2}, {x, -1, 1}, {y, -1, 1}];
dgraph = DiscretizeGraphics[Show[graph]];
RegionCentroid[dgraph]

(* {1.9645*10^-6, -1.44681*10^-6, 1.05721} *)

This works on 2D and 3D graphs. You can then use region functions, e.g., RegionCentroid to get the centroid of the whole graph.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.