8
$\begingroup$

My goal is to use "RegionCentroid" on a solid of revolution.

This works great for 2d regions:

reg = ImplicitRegion[0 <= y <= 20 - 2 x, {{x, 0, 10}, {y, 0, 20}}];

RegionPlot[reg]

RegionCentroid[reg]

I've been playing with my code for a while now and I can't seem to figure out how to revolve the region around the axis of my choice (in this case y)

$\endgroup$

1 Answer 1

14
$\begingroup$

You can use the new in V12.1 OpenCascaeLink to do something like this. It's not quite the way you want it but works well.

Define a 3D polygon of the surface you want to compute

pp = Polygon[{{0, 0, 0}, {10, 0, 0}, {0, 0, 20}}];
Graphics3D[pp]

enter image description here

Next, load the package and convert the polygon into an OpenCascade shape

Needs["OpenCascadeLink`"]
shape = OpenCascadeShape[pp];

Specify the axis around which you want to perform the rotational sweep and how much you want to sweep.

axis = {{0, 0, 0}, {0, 0, 25}};
sweep = OpenCascadeShapeRotationalSweep[shape, axis, 3 \[Pi]/2]

Extract the result as a boundary element mesh and visualize:

bmesh = OpenCascadeShapeSurfaceMeshToBoundaryMesh[sweep];
Show[Graphics3D[{{Red, pp}, {Blue, Thick, Arrow[axis]}}], 
 bmesh["Wireframe"], Boxed -> False]

enter image description here

Compute the region centroid:

RegionCentroid[MeshRegion[bmesh]]
{-0.767186, 0.767186, 5.0352}
$\endgroup$
2
  • $\begingroup$ (+1) Nice answer :) $\endgroup$ Apr 6, 2020 at 15:15
  • $\begingroup$ Thank you so much for the answer! i learned a lot from this $\endgroup$
    – Wombles
    Apr 7, 2020 at 23:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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