这又是一个一直没有深究过的问题,结果让人有点惊讶。总之看这个例子:
help[{x_, y_}] := (Sow@{x, y}; Exp[-x^2 - y^2])
{plot, {pts}} =
Reap@Plot3D[help@{x, y}, {x, -3, 3}, {y, -3, 3},
RegionFunction -> Function[{x, y}, x^2 + y^2 < 1], PlotRange -> All,
PlotPoints -> 50];
plot
pts // ListPlot
版本10新增的区域语法的行为则不同:
reg = ImplicitRegion[x^2 + y^2 < 1, {x, y}];
{plot2, {pts2}} =
Reap@Plot3D[help@{x, y}, {x, y} \[Element] reg, PlotRange -> All, PlotPoints -> 50];
pts2 // ListPlot
但是,两种情况下,域外的函数值都对作图效果造成了影响(新增的区域语法受的影响较小)。注意下面这两例的三维图边缘:
help2[{x_, y_}] := If[x^2 + y^2 <= 1, Exp[-x^2 - y^2], 1/0]
Plot3D[help2@{x, y}, {x, -3, 3}, {y, -3, 3},
RegionFunction -> Function[{x, y}, x^2 + y^2 < 1], PlotRange -> All,
PlotPoints -> 50]
Plot3D[help2@{x, y}, {x, y} \[Element] reg, PlotRange -> All, PlotPoints -> 50]
help[{x_, y_}] := (Sow@{x, y}; Exp[-x^2 - y^2])
{plot, {pts}} =
Reap@Plot3D[help@{x, y}, {x, -3, 3}, {y, -3, 3},
RegionFunction -> Function[{x, y}, x^2 + y^2 < 1], PlotRange -> All,
PlotPoints -> 50];
plot
pts // ListPlot
版本10新增的区域语法的行为则不同:
reg = ImplicitRegion[x^2 + y^2 < 1, {x, y}];
{plot2, {pts2}} =
Reap@Plot3D[help@{x, y}, {x, y} \[Element] reg, PlotRange -> All, PlotPoints -> 50];
pts2 // ListPlot
但是,两种情况下,域外的函数值都对作图效果造成了影响(新增的区域语法受的影响较小)。注意下面这两例的三维图边缘:
help2[{x_, y_}] := If[x^2 + y^2 <= 1, Exp[-x^2 - y^2], 1/0]
Plot3D[help2@{x, y}, {x, -3, 3}, {y, -3, 3},
RegionFunction -> Function[{x, y}, x^2 + y^2 < 1], PlotRange -> All,
PlotPoints -> 50]
Plot3D[help2@{x, y}, {x, y} \[Element] reg, PlotRange -> All, PlotPoints -> 50]