0
$\begingroup$

We can look at the dimension of a shape using RegionDimension, for example

RegionDimension /@ {Cuboid[], Cone[], Ball[]}

returns {3,3,3}. This is a 3D shape, i.e. it contains a volume (rather than say Sphere[]). This is very helpful when using RegionMember[].

But, now I want to create my very own shape. But all my Polygons have a RegionDimension of 2. , e.g.

shape = Polygon[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}}];
RegionDimension[shape]

Gives a result of 2. How can I create a custom 3D polygon that acts in the same way as Cuboid[] - can I make a combination of Cuboids[] & Cones[] in one shape?


Edit to clarify question further I wish to be able to create custom shapes in Mathematica that have the same properties as Cuboid[]. What I am hoping for is RegionMember to give the general expression for the requirement to be within the shape. E.g

shape0 = Cuboid[];
shape1 = ConvexHullMesh[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}, {0, 0, 0}}];
shape2 = DelaunayMesh[RandomReal[1, {50, 3}]];
shape3 = MeshRegion[{{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {1, 1, 2}}, {Tetrahedron[{1, 2, 3, 5}], Tetrahedron[{1, 3, 4, 5}]}];
shape4 = BoundingRegion[{{7, 6, 2}, {7, 10, 2}, {9, 2, 6}, {2, 9, 3}, {5, 4, 5}}, "MinConvexPolyhedron"];
shape5 = BoundaryDiscretizeGraphics[Prism[{{1, 0, 1}, {0, 0, 0}, {2, 0, 0}, {1, 2, 1}, {0, 2, 0}, {2, 2, 0}}]];


RegionMember[#, {x, y, z}] & /@ {shape0, shape1, shape2, shape3, 
  shape4, shape5}

Note how shape0 gives an expression, whereas the others remain in the shape form.

enter image description here

$\endgroup$
  • $\begingroup$ Try Tetrahedron instead of Triangle $\endgroup$ – Henrik Schumacher Jan 1 '18 at 20:58
  • $\begingroup$ RegionMember does evaluate on these shape when the second argument is numeric. I would say that the behavior of RegionMember on Cuboid[] is rather nonstandard. $\endgroup$ – Henrik Schumacher Jan 2 '18 at 5:26
1
$\begingroup$

A 3-point polygon in $\mathbb{R}^3$ defines a triangle, whose RegionDimension is 2. Mathematica is correct, and it's unclear what "hasn't been filled" means.

However, if you add a 4th point, you can generate a convex hull (one of many ways of defining 3d meshes):

shape = ConvexHullMesh[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}, {0, 0, 0}}, 
  Boxed -> True, PlotTheme -> "Detailed"]
RegionDimension@shape

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ It would be even simpler with Tetrahedron. Apart from that: good explanation. $\endgroup$ – Henrik Schumacher Jan 1 '18 at 21:07
  • $\begingroup$ This method gives a different behaviour using RegionMember than Cuboid[]. Why might this be? e.g RegionMember[shape, {x, y, z}] RegionMember[Cuboid[], {x, y, z}] . (it works fine for values for x,y &z). Why might that be? This doesn't seem a fit in replacement for Cuboid[] to be able to make custom shapes. $\endgroup$ – Tomi Jan 1 '18 at 22:53

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.