我有以下代码来绘制表面:
\documentclass[tikz,border=5mm]{standalone}
\usepackage{tikz,pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=-4,,zmax=5,zmin=-2,xmax=4,ymin=-4,ymax=4,axis lines=center,view={150}{20}]
\node [right] at (axis cs:6.2,0,0) {eixo-$x$};
\node [above] at (axis cs:0,6.2,0) {eixo-$y$};
\node [above] at (axis cs:0,0,5.1) {eixo-$z$};
\addplot3[surf,faceted color=teal,color=teal,opacity=0.5,fill opacity=0.2,opacity=0.5,domain=0:2,y domain=0:360,samples=40]
({x*cos(y)/sqrt(0.4)}, {1+x*sin(y)}, {x^2-1});
\end{axis}
\end{tikzpicture}
\end{document}
考虑到 xy 平面上的投影,我想将此表面旋转 30 度。我该怎么做?
答案1
这将使绘图绕 z 轴旋转。旋转角度为alphar
。根据您的惯例,您可能需要-30
。
\documentclass[tikz,border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=-4,,zmax=5,zmin=-2,xmax=4,ymin=-4,ymax=4,
axis lines=center,view={150}{20},declare function={alphar=30;
fx(\x,\y)=\x*cos(\y)/sqrt(0.4);fy(\x,\y)=1+x*sin(\y);}]
\node [right] at (axis cs:6.2,0,0) {eixo-$x$};
\node [above] at (axis cs:0,6.2,0) {eixo-$y$};
\node [above] at (axis cs:0,0,5.1) {eixo-$z$};
\addplot3[surf,faceted color=teal,color=teal,opacity=0.5,fill opacity=0.2,opacity=0.5,domain=0:2,y domain=0:360,samples=40]
({cos(alphar)*fx(x,y)+sin(alphar)*fy(x,y)},
{cos(alphar)*fy(x,y)-sin(alphar)*fx(x,y)}, {x^2-1});
\end{axis}
\end{tikzpicture}
\end{document}