如何用 TikZ 绘制具有高度和斜高的金字塔?

如何用 TikZ 绘制具有高度和斜高的金字塔?

如何用 TikZ 绘制具有高度(海拔)和斜高的金字塔。根据图enter image description here

答案1

答案2

您可以使用 来执行此操作tikz-3dplot

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{-20}
\begin{tikzpicture}[tdplot_main_coords,line cap=butt,line join=bevel]
\pgfmathsetmacro{\B}{4}
\pgfmathsetmacro{\H}{4}
 \draw[blue,thick] (-\B/2,-\B/2,0) -- (\B/2,-\B/2,0) -- (\B/2,\B/2,0) -- (-\B/2,\B/2,0) -- cycle;
 \draw[blue,thick] (\B/2,\B/2,0) -- (0,0,\H)
 node[above,font=\large\bfseries]{Regular Pyramid};
 \draw[dashed,blue] (0,0,0) -- (0,0,\H) coordinate[midway](aux1);
 \draw[blue] (0,0,0.3) -- (0.3,0,0.3) -- (0.3,0,0);
 \draw[dashed,blue] (-\B/2,0,0) -- (0,0,\H) coordinate[pos=0.3](aux2);
 \draw[blue] ({-\B/2+0.15*(\H/\B)},0,0.3) -- ({-\B/2+0.15*(\H/\B)},-0.3,0.3) -- 
 (-\B/2,-0.3,0);
 \coordinate (aux3) at (1,0,0);
 \draw[blue,thick,fill=cyan,fill opacity=0.3] (-\B/2,-\B/2,0) -- (0,0,\H) -- (\B/2,-\B/2,0) -- cycle;
 \draw[blue,thick,fill=blue,fill opacity=0.3] (-\B/2,-\B/2,0) -- (0,0,\H) -- (-\B/2,\B/2,0) -- cycle;
 \begin{scope}[tdplot_screen_coords]
  \draw (aux1) -- ++ (2,0.1) node[right,font=\itshape] {Altitude};
  \draw (aux2) -- ++ (-1.5,0.3) node[left,font=\itshape] {Slant Height};
  \draw (aux3) -- ++ (1,-1) node[below right,font=\itshape] {Base};
 \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

相关内容