RandomPoint doesn't seem to work
It works if you discretize the region first:
ℛ = DiscretizeRegion[
ImplicitRegion[(x - 2)^2 + (y - 3)^2 + (z - 8)^2 == 1, {x, y, z}],
MaxCellMeasure -> 0.00001
];
points = RandomPoint[ℛ, 500];
The trade-off is that the points do not lie exactly on the sphere; in this example, the is error about 0.01 percent which should be fine for statistical experiments.
I see this behaviour rather erroneous:
reg = ImplicitRegion[(x - 2)^2 + (y - 3)^2 + (z - 8)^2 == 1, {x, y, z}];
RegionPlot3D[reg]
leads to an empty plot, and
RandomPoint[reg]
RandomPoint[ ImplicitRegion[(-2 + x)^2 + (-3 + y)^2 + (-8 + z)^2 == 1, {x, y, z}]]
On the other hand, a similar construct in 2D works:
reg2 = ImplicitRegion[x^2 + y^2 == 1, {x, y}];
RandomPoint[reg2]
{0.961994, 0.27307}
while
RegionPlot[reg2]
gives an empty plot, too.
The behaviour of RegionPlot3D
is explained in the docs:
RegionPlot3D[pred,....]
The predicate pred can be any logical combination of inequalities.
Moreover:
RegionPlot3D initially evaluates pred at a 3D grid of equally spaced sample points specified by PlotPoints. Then it uses an adaptive algorithm to subdivide at most MaxRecursion times, attempting to find the boundaries of all regions in which pred is True.
The same can be found in the docs of RegionPlot
. Ok, so we shouldn't expect the plots to work.
BUT:
Recall that RandomPoint[reg]
didn't work; consider instead
reg3 = ImplicitRegion[(x - 2)^2 + (y - 3)^2 - (z - 8)^2 == 1, {x, y, z}];
where I only changed the sign before $(z-8)^2$. Then:
RandomPoint[reg3]
{6.81984, 4.05919, 3.16754}
with an error:
RandomPoint::unbndreg: The specified region appears to be unbounded. Appropriate bounds will be automatically computed. Explicit bounds may be specified as a third argument.
which can be easily dealt with by providing the third argument:
RandomPoint[reg3, 1, {{-10, 10}, {-10, 10}, {-10, 10}}]
{{-2.33781, 2.75421, 3.77188}}
Hence, I see no reason why RandomPoint
, working for reg3
, shouldn't work for reg
.
It works if we define a finite-thickness shell:
eps = .001;
p = RandomPoint[
ImplicitRegion[
1 - eps <= (x - 2)^2 + (y - 3)^2 + (z - 8)^2 <= 1 + eps, {x, y,
z}], 1000];
If you make eps
smaller it seems to work but becomes extremely slow.