I have to draw some shapes to remind my students of the rules for volumes.
Please, I want to draw a pyramid with a square base, can anyone help? (V=1/3 x y h)
I have to draw some shapes to remind my students of the rules for volumes.
Please, I want to draw a pyramid with a square base, can anyone help? (V=1/3 x y h)
You can try this code.
\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}