圆锥曲线可视化

学习圆锥曲线的时候一直感觉课本上那个图很好看,所以也来画画看。

接着上面的文章,先画没有圆柱的:

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

这次加圆柱反而比较困难,因为这次我想把交贯线画出来:

ContourPlot3D[{x - z/3 + 1/2 , y^2 + x^2 - z^2 == 0}, {x, -2, 
  2}, {y, -2, 2}, {z, -2, 2}, ContourStyle -> Opacity[0.5], 
 PlotPoints -> 20, Mesh -> None, 
 ColorFunction -> CreateColorFunction[Paired, 4], 
 BoundaryStyle -> {1 -> None, 
   2 -> None, {1, 2} -> { {Green, Tube[.03]} } }, Boxed -> False]

其实最好的办法不是像上面那样话。可以这样来,而且好处是你可以调节圆锥的参数使得两个的配比更为合适,这里仅仅调整了透明度。

cone = ContourPlot3D[
  y^2 + x^2 - z^2 == 0, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
  ContourStyle -> Opacity[0.2], PlotPoints -> 20, 
  ColorFunction -> CreateColorFunction[Paired, 4], Mesh -> None, 
  BoundaryStyle -> None, Boxed -> False];
Show[p, cone]

亲,给点评论吧!