我才知道就算设了RegionFunction,Plot系函数照样会全域取样啊
mathematica吧
全部回复
仅看楼主
吧务
level 15
xzcyr 楼主
这又是一个一直没有深究过的问题,结果让人有点惊讶。总之看这个例子:
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]
2023年06月03日 15点06分 1
吧务
level 13
推测 Plot3D 的 RegionFunction 是传 {x,y,z} 参数的, 获得 z 需要对 {x,y} 取样
2023年06月04日 02点06分 3
1