如何畫出兩個隱函數曲面的交線?
比如:
其中一個曲面為:x^2+y^2+z^2=1;
另外一個曲面為:x*(y-1)+y*sin(x+3*z)+z*x^2=0;在空間直角坐標系中:僅保留兩個曲面的交線,如何畫?
用 Mathematica代碼如下:
ContourPlot3D[{x^2 + y^2 + z^2 - 1,
x*(y - 1) + y*Sin[x + 3*z] + z*x^2}, {x, -1.1, 1.1}, {y, -1.1,
1.1}, {z, -1.1, 1.1}, Contours -&> {0}, ContourStyle -&> Opacity[0],
Mesh -&> None,
BoundaryStyle -&> {1 -&> None,
2 -&> None, {1, 2} -&> {{Green, Tube[.03]}}}, Boxed -&> False]
效果
去掉
Mesh -&> None,
的效果
參考:Plotting implicitly-defined space curves
補充一下MATLAB的寫法:
[x,y,z] = meshgrid(-1:.01:1);
f1 = x.^2+y.^2+z.^2-1;
f2 = x.*(y-1)+y.*sin(x+3*z)+z.*x.^2;
isosurface(x,y,z,abs(f1)+abs(f2),0.03)
axis image,view(34,29)
fv1 = reducepatch(isosurface(x,y,z,f1,0),0.005); % 減少面數,否則太密
fv2 = reducepatch(isosurface(x,y,z,f2,0),0.005);
set(patch(fv1),"facecolor","none","edgealpha",0.2) % 調整透明度,以突出交線
set(patch(fv2),"facecolor","none","edgealpha",0.2)
推薦閱讀:
※為什麼 MATLAB 矩陣為縱向存儲,有什麼好處?
※常見的MATLAB初學者問題中,哪些讓你非常無語或者覺得值得吐槽?
※關於機器學習的應用一般都用什麼語言和平台?具體到視頻分析用什麼軟體來分析?
※語音端點檢測matlab程序實現?
※matlab灰色預測模型GM(1,1)代碼。?
TAG:MATLAB | WolframMathematica |