绘制 3D 图片

绘制 3D 图片

我怎样才能画出这个形状?

谢谢

\documentclass{article}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}

    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

这是一个快速适应亨利·门克的代码

\documentclass{standalone}
\usepackage{asypictureB}

\begin{document}

\begin{asypicture}{name=hyperboloid}
settings.outformat="pdf";
settings.render = 16;
settings.prc = false;
import three;
import graph;

size(8cm,8cm);

currentprojection = perspective(3*(0.1,1,0), up=Y);

pen color = yellow;
material surfacepen = material(diffusepen=color+opacity(1.0), emissivepen=0.5*color);
pen color = blue;
material planepen = material(diffusepen=opacity(0.4), emissivepen=0.8*color);

real f(real x) { return .5*x*x+.5; }
path3 p3 = path3(graph(f, -1, 1, operator..));

surface solidsurface = surface(p3, c=O, axis=X);
draw(solidsurface, surfacepen=surfacepen);

draw(3Y-0.2Z -- 3Y+0.2Z,
L=Label("$x$",position=MidPoint),arrow=Arrow3(TeXHead3));

\end{asypicture}
\end{document}

在此处输入图片描述

以上内容可以用 进行编译pdflatex -shell-escape

或者,您可以使用

\documentclass[varwidth,margin=3mm]{standalone}
\usepackage{asymptote}
\begin{document}
\begin{asy}
settings.outformat="pdf";
settings.render = 16;
settings.prc = false;
import three;
import graph;

size(8cm,8cm);

currentprojection = perspective(3*(0.1,1,0), up=Y);

pen color = yellow;
material surfacepen = material(diffusepen=color+opacity(1.0), emissivepen=0.5*color);
pen color = blue;
material planepen = material(diffusepen=opacity(0.4), emissivepen=0.8*color);

real f(real x) { return .5*x*x+.5; }
path3 p3 = path3(graph(f, -1, 1, operator..));

surface solidsurface = surface(p3, c=O, axis=X);
draw(solidsurface, surfacepen=surfacepen);

draw(3Y-0.2Z -- 3Y+0.2Z,
L=Label("$x$",position=MidPoint),arrow=Arrow3(TeXHead3));
\end{asy}
\end{document}

假设此文件名为test.tex,运行

pdflatex test
asy test-1.asy
pdflatex test

在以上所有内容中,您可以pdflatexlualatex或替换xelatex,这也应该有效。

如果asymptote由于某种原因失败了,这里有一个(当然相对较差的)pgfplots替代方案。

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}%<- change on older installations
\begin{document}
\begin{tikzpicture}
\begin{axis}[hide axis,shader=interp,
    axis equal image,scale=2,view/el=4,view/az=0,
    colormap={pft}{rgb255(0cm)=(255,127,0);
    rgb255(1cm)=(255,255,0);rgb255(2cm)=(255,255,200)},
    point meta=-(y-1.5)*(y-1.5)*(1+x*x)/1.5-2*(z+2)*(z+2)-x*x,z buffer=sort]
 \addplot3[surf,domain=-2:2,
 domain y=\pgfkeysvalueof{/pgfplots/view/az}-180:\pgfkeysvalueof{/pgfplots/view/az}]
  ({sqrt(x*x+1)*cos(y)},{sqrt(x*x+1)*sin(y)},{(1-0.1*sin(y-\pgfkeysvalueof{/pgfplots/view/az}))*x}); 
 \draw[semithick,-latex] (1.6,0,-0.7) -- (1.6,0,0.7) node[midway,right]{$X_0$}; 
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容