I'm trying to get a list of points inside a 3D region. However, I want these points to have a certain spacing in x-, y- and z-directions.
As of now I generate a list of points with the appropriate spacing and use Select
with an appropriate RegionMemberFunction
to filter for the desired points. This generates quite a bit of useless data, as millions of points get discarded after the use of Select
.
An example:
h = 100;
r = 100;
rm = RegionMember[Cone[{{0, 0, 0}, {0, 0, h}}, r]];
pts = ParallelTable[{x, y, z}, {x, -r/2, r/2, r/100}, {y, -r/2, r/2,
r/100}, {z, 0, h, h/100}];
selpts = Select[rm]@Flatten[pts, 2]
Around 1 million points are generated by pts
, but around 50% are discarded for the desired points selpts
. Is there a way to generate only points inside the desired 3D region without the overhead?
RandomPoint[Cone[{{0, 0, 0}, {0, 0, h}}, r], 100]
$\endgroup$