我想画如下图所示的砖窑。请帮我在抛物线环形墙上贴砖。
先感谢您!
MWE 是
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{3d,calc}
\begin{document}
\begin{tikzpicture}[declare function={xd=1.1*ln(3 + 2*sqrt(2));},>=stealth,x={(1cm,-0.1cm)},
y={(0,0.85cm)},z={(1cm,0.25cm)}]
\draw[->] (-3,0)--+(6,0); %x-axis
\draw[->] (0,-1)--+(0,4.5); %y-axis
\draw (0,2.2,0)--+(0,0,4) %segments
(xd,0,0)--+(0,0,4);
\draw[dashed] (-xd,0,0)--+(0,0,4);
\begin{scope}[canvas is xy plane at z=0] %hyperbol
\clip (-3,0) rectangle +(6,4);
\draw[samples=200,domain=-3:3,variable=\x,,smooth] plot ({\x}, {3-cosh(\x)});
\draw[scale=1.1,samples=200,domain=-3:3,variable=\x,,smooth] plot ({\x}, {3-cosh(\x)});
\end{scope}
\begin{scope}[canvas is xy plane at z=4]
\clip (-3,0) rectangle +(6,4);
\draw[scale=1.1,samples=200,domain=0:3,variable=\x,,smooth] plot ({\x}, {3-cosh(\x)});
\draw[dashed,scale=1.1,samples=200,domain=-3:0,variable=\x,,smooth] plot ({\x}, {3-cosh(\x)});
\end{scope}
\end{tikzpicture}
\end{document}
答案1
第一种方法可能是这样的:
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{3d,perspective}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,isometric view,rotate around z=180]
\pgfmathsetmacro\fd{ln(3+2*sqrt(2))} % function domain
\pgfmathsetmacro\ty{0.9} % tangente point y (approx)
\pgfmathsetmacro\tz{3.3-1.1*cosh(\ty)} % tangent point z
% inner wall
\begin{scope}
\clip plot[samples=51,domain=-\ty:-\fd] ( 0,\x,{3-cosh(\x)}) --++ (-2,0,0) --
plot[samples=51,domain=-\fd:-\ty] (-2,\x,{3-cosh(\x)}) -- cycle;
\foreach[count=\ii]\i in {\fd,1.70,1.63,1.55,1.46,1.36,1.25,1.13,1} % approximations
{
\pgfmathsetmacro\os{mod(\ii,2)==1?0.125:0.375}
\ifnum\ii >1
\foreach\j in {0,-0.5,...,-4}
\pgfmathparse{50*rnd+50}
\draw[brown,fill=brown!\pgfmathresult] (\j+\os,-\li,{3-cosh(\li)}) --
(\j+\os-0.5,-\li,{3-cosh(\li)}) --
(\j+\os-0.5,-\i,{3-cosh(\i)}) --
(\j+\os,-\i,{3-cosh(\i)}) -- cycle;
\fi
\global\let\li=\i % Remember \i
}
\end{scope}
\draw[brown] plot[samples=51,domain=-\ty:-\fd] ( 0,\x,{3-cosh(\x)}) --++ (-2,0,0) --
plot[samples=51,domain=-\fd:-\ty] (-2,\x,{3-cosh(\x)}) -- cycle;
% outer wall
\begin{scope}
\clip plot[samples=51,domain=-\ty:\fd] ( 0,{1.1*\x},{3.3-1.1*cosh(\x)}) --++ (-4,0,0) --
plot[samples=51,domain=\fd:-\ty] (-4,{1.1*\x},{3.3-1.1*cosh(\x)}) -- cycle;
\foreach[count=\ii]\i in {\fd,1.70,1.63,1.55,1.46,1.36,1.25,1.13,1,0.86, % approximations
0.71,0.55,0.38,0.2,0,-0.2,-0.38,-0.55,-\ty}
{
\pgfmathsetmacro\os{mod(\ii,2)==1?0.125:0.375}
\ifnum\ii >1
\foreach\j in {0,-0.5,...,-4}
\pgfmathparse{50*rnd+50}
\draw[brown,fill=orange!\pgfmathresult] (\j+\os,1.1*\li,{3.3-1.1*cosh(\li)}) --
(\j+\os-0.5,1.1*\li,{3.3-1.1*cosh(\li)}) --
(\j+\os-0.5,1.1*\i,{3.3-1.1*cosh(\i)}) --
(\j+\os,1.1*\i,{3.3-1.1*cosh(\i)}) -- cycle;
\fi
\global\let\li=\i % Remember \i
}
\end{scope}
\draw[brown] plot[samples=51,domain=-\ty:\fd] ( 0,{1.1*\x},{3.3-1.1*cosh(\x)}) --++ (-4,0,0) --
plot[samples=51,domain=\fd:-\ty] (-4,{1.1*\x},{3.3-1.1*cosh(\x)}) -- cycle;
% side wall and axes
\draw[brown,fill=brown!20] plot[samples=51,domain=-\fd:\fd] (0,{1.1*\x},{3.3-1.1*cosh(\x)}) -- (0,\fd,0) --
plot[samples=51,domain=\fd:-\fd] (0,\x,{3-cosh(\x)}) -- cycle;
\draw[-latex] (0,-3,0) -- (0,3,0) node [right] {$x$};
\draw[-latex] (0, 0,0) -- (0,0,3) node [above] {$y$};
\end{tikzpicture}
\end{document}
您可以通过创建一些函数来减少代码,而且通过改变一些近似值(砖块的高度、切点)肯定可以改进代码。