5
$\begingroup$

Suppose you have a list of data points, either in 2D or 3D; is it possible to plot the minimal bounding region containing all the points?

Ignoring holes etc.

$\endgroup$
  • $\begingroup$ my gut instinct is that InterpolationPoint might be the option to consider $\endgroup$ – MKF Mar 6 at 17:34
  • 3
    $\begingroup$ Are you looking for ConvexHullMesh? $\endgroup$ – MarcoB Mar 6 at 17:43
  • $\begingroup$ Exactly! is there a way to apply smoothing to it? and perhaps some opacity? $\endgroup$ – MKF Mar 6 at 17:45
  • $\begingroup$ Opacity: sure, it's somewhere in the options. What do you mean by "smoothing" though? Do you have an example in mind? $\endgroup$ – MarcoB Mar 6 at 17:48
  • $\begingroup$ It seems convexhullmesh will give a quite polygonal/linear shape. Is there anyway to somehow round the shape? $\endgroup$ – MKF Mar 6 at 17:50
6
$\begingroup$

For the 2D case, you can use the shape of the joint to give rounded corners to your shape. For instance:

pts = RandomReal[{-5, 5}, {20, 2}];
ConvexHullMesh[pts]

hull

Retrieve the mesh expressed as a Polygon object and style to your liking:

Graphics[{
  Darker@Blue, 
  EdgeForm[{Darker@Blue, Thickness[0.09], JoinForm["Round"]}],
  Cases[Normal[chm["Graphics"]], _Polygon, All]
}]

styled

$\endgroup$
  • $\begingroup$ Awesome, thanks again! $\endgroup$ – MKF Mar 6 at 18:32
  • $\begingroup$ @MKF You are welcome! $\endgroup$ – MarcoB Mar 6 at 18:33
7
$\begingroup$

Given a set of random 3D points, you can create a mesh that represents the minimum bounding region using BoundingRegion[] or ConvexHullMesh[] as MarcoB suggested. ConvexHullMesh[] is probably the simplest, though BoundingRegion[] has some nice options for other sorts of regions like the smallest sphere or cuboid.

BlockRandom[SeedRandom[1234]; pts = RandomReal[{-1, 1}, {50, 3}];]
cvx = ConvexHullMesh[pts]
br = BoundingRegion[pts, "MinConvexPolyhedron"]

This should give you two meshes that look identical to this:

Convex hull mesh of random 3d points.

You can choose whichever function you prefer. It's also possible to show the points themselves along with the mesh:

Show[HighlightMesh[br, Style[2, Opacity[0.5]]], Graphics3D[Point[pts]]]

Convex hull mesh of random 3d points with points shown.

$\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.