6
$\begingroup$

As the title describes, specifically, simple code below

ConvexHullMesh[RandomReal[1, {10, 2}]]["Centroid"]

returns an error in V. 12.2, but it worked in V. 12.1.1 as far as I remember

BoundaryMeshRegion::unsupported

Is it a bug introduced by the new version? Or is there another way to get the centroid?


Update

I just find it that not only "Centroid", but also extractions of other "Properites" fail; except for "BoundaryPolygons".


Update 2

To make this problem more understandable, let me make some modifications to the code.

mesh = ConvexHullMesh[RandomReal[1, {10, 2}]];
mesh["Properties"]

This would return a long List of strings as the properties mesh has. And then

mesh[str]

would return something, at least without any error message, where str is arbitrary one of the elements of the aforementioned property List; very much like OOP (objective-oriented programming). And that is what would happen in former versions like V. 12.1.1.

However now in V. 12.2, mesh["Centroid"] fails, even though "Centroid" can be found in that property List of mesh.

$\endgroup$
5
  • 1
    $\begingroup$ RegionCentroid[ConvexHullMesh[RandomReal[1, {10, 2}]]] ? $\endgroup$
    – cvgmt
    Commented Dec 25, 2020 at 8:56
  • 1
    $\begingroup$ @cvgmt Thx very much, it works for the data extraction. But it only solves half of the problem. I doubt that something is wrong with BoundaryMeshRegion in the new version, isn't it? $\endgroup$ Commented Dec 25, 2020 at 9:00
  • $\begingroup$ MeshPrimitives@ConvexHullMesh[RandomReal[1, {10, 2}]] ? What is the "Properites" $\endgroup$
    – cvgmt
    Commented Dec 25, 2020 at 9:46
  • $\begingroup$ @cvgmt Plz see my Update 2. $\endgroup$ Commented Dec 25, 2020 at 9:55
  • 1
    $\begingroup$ Perhaps we need to be reminded that these properties are actually undocumented stuff, so there is no guarantee that they should still work in future versions. $\endgroup$ Commented Dec 26, 2020 at 14:02

1 Answer 1

8
$\begingroup$

Accessing properties of BoundaryMeshRegion that way was undocumented and therefore might not work anymore in 12.2.

A somewhat documented way is the AnnotationValue approach. Eg.

AnnotationValue[{ConvexHullMesh[RandomReal[1, {10, 2}]], 1}, MeshCellMeasure]

But this doesn't work for all properties either (also see Possible Issues section). In that case Centroid is not working.

What is still working is this also undocumented approach:

mesh = Graphics`Region`ToMeshObject[ConvexHullMesh[RandomReal[1, {10, 2}]]];
mesh["Centroid"]
$\endgroup$

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.