在Mathematica中用
RegionFunction->Function[{x,y,z},x^2+y^2<9]
定义这个曲面的作图区域 (这里的作图区域为 x^2+y^2<9)
以下以抛物面 z=x^2+y^2 的图形为例。
图1
这个图形的Mathematica命令:
f[x_,y_]:=x^2+y^2;
Plot3D[f[x,y],{x,-1,1},{y,-1,1},PlotPoints->{10,10},BoxRatios->{1,1,1}] (对作图区域没有附加限制)
图2
这个图形的Mathematica命令:
f[x_,y_]:=x^2+y^2;
Plot3D[f[x,y],{x,-1,1},{y,-1,1},PlotPoints->{10,10},BoxRatios->{1,1,1}, RegionFunction->Function[{x,y,z},x^2+y^2<1] ]
(作图区域为圆域:x^2+y^2<1 )
图3
这个图形的Mathematica命令:
f[x_,y_]:=x^2+y^2;
Plot3D[f[x,y],{x,-1,1},{y,-1,1},PlotPoints->{10,10},BoxRatios->{1,1,1}, RegionFunction->Function[{x,y,z},x y+z<1/2] ]
(作图区域:xy+z<1/2)
这三个图形的Mathematica命令:
f[x_,y_]:=x^2+y^2;
Plot3D[f[x,y],{x,-1,1},{y,-1,1},PlotPoints->{10,10},BoxRatios->{1,1,1}]
Plot3D[f[x,y],{x,-1,1},{y,-1,1},PlotPoints->{10,10},BoxRatios->{1,1,1}, RegionFunction->Function[{x,y,z},x^2+y^2<1]]
Plot3D[f[x,y],{x,-1,1},{y,-1,1},PlotPoints->{10,10},BoxRatios->{1,1,1}, RegionFunction->Function[{x,y,z},x y+z<1/2]]
其它例子
例1 圆台的侧面
a=1.2;
f[x_,y_]:=x^2+y^2;
Qumian=Plot3D[f[x,y],{x,-a,a},{y,-a,a},Mesh->{0,0},PlotStyle->{GrayLevel[0.7],Specularity[White,8],Green},Lighting->"Neutral",PlotPoints->{10,10},BoxRatios->{1,1,1},
RegionFunction->Function[{x,y,z},0.2<z<0.8], (作图区域为:0.2<z<0.8)
BoundaryStyle->Directive[Red,Thickness[0.01]]];
X=ParametricPlot3D[{x,0,0},{x,-4,4},PlotStyle->AbsoluteThickness[3]];
Y=ParametricPlot3D[{0,y,0},{y,-4,4},PlotStyle->AbsoluteThickness[3]];
Z=ParametricPlot3D[{0,0,z},{z,0,4},PlotStyle->AbsoluteThickness[3]];
XYZ=Show[X,Y,Z];
Show[Qumian,XYZ,PlotRange->{{-a,a},{-a,a},{0,1.2}},Boxed->False,Axes->False,ViewPoint->{6,4,2}]
例2 球面的一部分
Qumian=ParametricPlot3D[{Sin[u] Cos[v],Sin[u] Sin[v],Cos[u]},{u,0,Pi},{v,0,2Pi},Mesh->{5,0},PlotStyle->{GrayLevel[0.7],Specularity[White,20],Hue[0.32]},Lighting->"Neutral",BoundaryStyle->Directive[Red,Thickness[0.01]],
RegionFunction->Function[{x,y,z,u,v},0.2Pi<u<0.7Pi && 0.3Pi<v<1.8Pi]]; (对参数予以控制)
X=ParametricPlot3D[{x,0,0},{x,-2,2},PlotStyle->AbsoluteThickness[3]];
Y=ParametricPlot3D[{0,y,0},{y,-2,2},PlotStyle->AbsoluteThickness[3]];
Z=ParametricPlot3D[{0,0,z},{z,-2,2},PlotStyle->AbsoluteThickness[3]];
XYZ=Show[X,Y,Z];
Show[Qumian,XYZ,PlotRange->{{-1.3,1.3},{-1.3,1.3},{-1.3,1.3}},Boxed->False,Axes->False,ViewPoint->{6,2,2}]
例3 椭球面挖洞
a=1.8;b=2;c=1.4;
x[u_,v_]:=a Sin[u] Cos[v];
y[u_,v_]:=b Sin[u] Sin[v];
z[u_,v_]:=c Cos[u];
Qumian=ParametricPlot3D[{x[u,v],y[u,v],z[u,v]},{u,0,Pi},{v,0,2Pi},Mesh->0,PlotStyle->{GrayLevel[0.9],Specularity[White,7],Hue[0.6,0.7,0.4],Opacity[0.9]},Lighting->"Neutral",BoundaryStyle->Directive[Red,Thickness[0.005]],
RegionFunction->Function[{x,y,z},0.4<2y^2+z^2 && Abs[x]+Abs[z]>0.5 ]];
(作图区域是两个区域之交集: 0.4<2y^2+z^2 和 Abs[x]+Abs[z]>0.5 的交集)
X=ParametricPlot3D[{x,0,0},{x,-2,2.7},PlotStyle->AbsoluteThickness[3]];
Y=ParametricPlot3D[{0,y,0},{y,-2,2.7},PlotStyle->AbsoluteThickness[3]];
Z=ParametricPlot3D[{0,0,z},{z,-2,2},PlotStyle->AbsoluteThickness[3]];
XYZ=Show[X,Y,Z];
Show[Qumian,XYZ,PlotRange->{{-2,2.7},{-2,2.7},{-1.8,2.3}},Boxed->False,Axes->False,ViewPoint->{4,3,2}]
评论