There appears to be a bug in RandomPoint
, as can be seen by plotting both region1
and region2
, the latter defined by
region2 = ImplicitRegion[6 <= x - y + 2*z <= 7,
{{x, -5*Pi, 5*Pi}, {y, -5*Pi, 5*Pi}, {z, -10, 10}}];
Then
pts2 = RandomPoint[region2, 10^4];
ListPointPlot3D[{pts2, pts1}, AxesLabel -> {"x", "y", "z"}, BoxRatios -> {1, 1, 1},
PlotRange -> {{x, -5*Pi, 5*Pi}, {y, -5*Pi, 5*Pi}, {z, -10, 10}},
PlotStyle -> {Brown, Blue}]
It is natural to ask whether region1
actually stops where shown here. It does not. For instance,
NMaximize[z, {x, y, z} ∈ region1]
(* {10., {x -> -10.7241, y -> 2.59226, z -> 10.}} *)
That the fault lies with RandomPoint
also can be seen from
Max[Cases[pts1, {_, _, z_} -> z]]
(* 7.67556 *)
Workaround
One way to recover the missing upper portion of the region1
plot is
region3 = ImplicitRegion[equation1 && 6 <= x - y + 2*z <= 7,
{{x, -5*Pi, 5*Pi}, {y, -5*Pi, 5*Pi}, {z, 7, 10}}];
pts3 = RandomPoint[region3, 1.5 10^3];
ListPointPlot3D[{pts2, pts1, pts3}, AxesLabel -> {"x", "y", "z"}, BoxRatios -> {1, 1, 1},
PlotRange -> {{x, -5*Pi, 5*Pi}, {y, -5*Pi, 5*Pi}, {z, -10, 10}},
PlotStyle -> {Brown, Blue, Red}]
A similar workaround could be used to recover the small portion of region1
missing at the bottom of the plot.
It is natural to ask why the lower bound in z
in region3
is not set at 7.67556
, so that there is no overlap between region1
and region3
. It turns out that RandomPoint
generates no points below about z = 8
in that case. To eliminate the overlapping region of points, one could use DeleteCases
.
ListPointPlot3D
also seems to behave strangely, effectively ignoring PlotRange
. So, for instance,
plt3 = ListPointPlot3D[pts3, AxesLabel -> {"x", "y", "z"}, BoxRatios -> {1, 1, 1},
PlotRange -> {{x, -5*Pi, 5*Pi}, {y, -5*Pi, 5*Pi}, {z, -10, 10}}]
Options[plt3, PlotRange]
(* {PlotRange -> {{-15.7075, 6.41088}, {-7.15594, 15.7007}, Automatic}} *)
I leave it to others to decide whether this is a bug in ListPointPlot3D
. Certainly the treatment of PlotRange
differs from that in ListPlot
.
For the record,
$Version
(* "10.2.0 for Microsoft Windows (64-bit) (July 7, 2015)" *)
RandomPoint[]
is being fixed, have you seen this? $\endgroup$