圆柱交贯线可视化

绘制曲线方程Mathematica非常有一套,这里演示下如何用Mathematica画圆柱的交贯线。

两个圆柱都要出现的话,最简单:

ContourPlot3D[{x^2 + z^2 - 1 == 0, y^2 + x^2 - 1/2 == 0}, {x, -2, 
  2}, {y, -2, 2}, {z, -2, 2}, ContourStyle -> Opacity[0.5], 
 Mesh -> None, PlotPoints -> 20, Boxed -> False, ImageSize -> Large, 
 PlotTheme -> "Web"]

不要一个圆柱的话,建议的做法是使用MeshFunction选项:

ContourPlot3D[x^2 + z^2 - 1 == 0, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
 ContourStyle -> Opacity[0.5], PlotPoints -> 20,
 MeshFunctions -> Function[{x, y, z}, y^2 + x^2 - 1], 
 MeshStyle -> {Thick, Red},
 Mesh ->0.5, BoundaryStyle -> None, Boxed -> False]

两个都不要的话,很简单:

ContourPlot3D[x^2 + z^2 - 1 == 0, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
 ContourStyle -> Opacity[0], PlotPoints -> 20,
 MeshFunctions -> Function[{x, y, z}, y^2 + x^2 - 1], 
 MeshStyle -> {Thick, Red},
 Mesh ->0.5, BoundaryStyle -> None, Boxed -> False]

要来个立体的交贯线的话,就改改MeshStyle:

ContourPlot3D[x^2 + z^2 - 1 == 0, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
 ContourStyle -> Opacity[0], PlotPoints -> 20,
 MeshFunctions -> Function[{x, y, z}, y^2 + x^2 - 1], 
 MeshStyle -> {Tube[0.05]},
 Mesh ->0.5, BoundaryStyle -> None, Boxed -> False

开头那个样子的图像呢,就是这样:

ContourPlot3D[x^2 + z^2 - 1 == 0, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
 ContourStyle -> Opacity[0.5], PlotPoints -> 20,
 MeshFunctions -> Function[{x, y, z}, y^2 + x^2 - 1], 
 MeshStyle -> {Tube[0.03]},
 Mesh -> {Range[-1, 0, .2]}, 
 ColorFunction -> CreateColorFunction[Paired, 4],
 BoundaryStyle -> None, Boxed -> False]

怎么样,是不是很强大。同样的方法还可以画各种类型的曲面的交贯线。

亲,给点评论吧!