我必须画一些形状来提醒我的学生体积规则。
请问,我想画一个底座为正方形的金字塔,有人可以帮忙吗?(V=1/3 xyh)
答案1
你可以尝试一下这个代码。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz,tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{120}
\begin{tikzpicture}[tdplot_main_coords,line cap=butt,line join=round,c/.style={circle,fill,inner sep=1pt},
declare function={a=4;h=3;}]
\path
(0,0,0) coordinate (A)
(a,0,0) coordinate (B)
(a,a,0) coordinate (C)
(0,a,0) coordinate (D)
(a/2,a/2,0) coordinate (O)
(a/2,a/2,h) coordinate (S);
\draw (S) -- (D) -- (C) -- (B) -- cycle (S) -- (C);
\draw[dashed] (S) -- (A) --(D) (A) -- (B) (S) -- (O);
\path foreach \p/\g in {A/-90,B/-90,C/-90,D/-90,S/90,O/0}{(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
\end{tikzpicture}
\tdplotsetmaincoords{70}{120}
\begin{tikzpicture}[tdplot_main_coords,line cap=butt,line join=round,c/.style={circle,fill,inner sep=1pt},
declare function={a=4;h=3;}]
\path
(0,0,0) coordinate (A)
(a,0,0) coordinate (B)
(a,a,0) coordinate (C)
(0,a,0) coordinate (D)
(0,0,h) coordinate (S);
\draw (S) -- (D) -- (C) -- (B) -- cycle (S) -- (C);
\draw[dashed] (S) -- (A) --(D) (A) -- (B);
\path foreach \p/\g in {A/-90,B/-90,C/-90,D/-90,S/90}{(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
\end{tikzpicture}
\end{document}