2

I have the following code (stolen from Are there simple ways to draw parallelepipeds in tikz? and adjusted)

\documentclass[border=2mm,12pt,tikz]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
 \tdplotsetmaincoords{70}{60}
   \begin{tikzpicture}[scale=1,line cap=butt,line join=round,tdplot_main_coords,declare function={a=3;b=4;h=3;k=2;
   }] 
    \begin{scope}[canvas is xy plane at z=0]
    \path
    (0,0) coordinate (A) 
     (a,0) coordinate (B)
      (a,b) coordinate (C)
      (0,b) coordinate (D);
    \end{scope}
    \begin{scope}[canvas is xy plane at z=h]
 \path
 (0,k) coordinate (A') 
 (a,k) coordinate (B')
 (a,b+k) coordinate (C')
 (0,b+k) coordinate (D');
 \end{scope}  
 \begin{scope}[opacity=0.3,thick]
\draw[fill=orange] (A) --(B)  -- (C) -- (D) -- cycle;
\draw[fill=orange] (A) --(B)  -- (B') -- (A') -- cycle;
\draw[fill=orange] (B) --(C)  -- (C') -- (B') -- cycle;
\draw[fill=orange] (C) --(D)  -- (D') -- (C') -- cycle;
\draw[fill=orange] (A) --(D)  -- (D') -- (A') --cycle;
\draw[fill=orange] (A') --(B')  -- (C') -- (D') --cycle;
\end{scope}
\end{tikzpicture}
\end{document} 

which renders as

para

I only want to add arrows like this, so it is obvoius that the parallelepiped is created by these three vectors.

para2

Thanks all!

2 Answers 2

4

Very similar to @Raffaele Santoro answer_

\documentclass[border=2mm,12pt,tikz]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows.meta}

\begin{document}
 \tdplotsetmaincoords{70}{60}
   \begin{tikzpicture}[
line cap=butt,  line join=round,
tdplot_main_coords,
declare function={a=3;b=4;h=3;k=2;}
   ]
    \begin{scope}[canvas is xy plane at z=0]
    \path
    (0,0) coordinate    (A)
    (a,0) coordinate    (B)
    (a,b) coordinate    (C)
    (0,b) coordinate    (D);
    \end{scope}
    \begin{scope}[canvas is xy plane at z=h]
 \path
 (0,k) coordinate (A')
 (a,k) coordinate (B')
 (a,b+k) coordinate (C')
 (0,b+k) coordinate (D');
 \end{scope}
 \begin{scope}[opacity=0.3,thick]
\draw[fill=orange] (A) --(B)  -- (C) -- (D) -- cycle;
\draw[fill=orange] (A) --(B)  -- (B') -- (A') -- cycle;
\draw[fill=orange] (B) --(C)  -- (C') -- (B') -- cycle;
\draw[fill=orange] (C) --(D)  -- (D') -- (C') -- cycle;
\draw[fill=orange] (A) --(D)  -- (D') -- (A') --cycle;
\draw[fill=orange] (A') --(B')  -- (C') -- (D') --cycle;
\end{scope}
% new
    \begin{scope}[every edge/.style={draw, thick, -{Straight Barb[scale=0.8]}}]
\draw (B) edge (A)  (B) edge (C)    (B) edge (B');
    \end{scope}
\end{tikzpicture}
\end{document} 

enter image description here

3

Your code completed:

\documentclass[border=2mm,12pt,tikz]{standalone}
    \usepackage{tikz-3dplot}
    \begin{document}
        \tdplotsetmaincoords{70}{60}
        \begin{tikzpicture}[scale=1,line cap=butt,line join=round,tdplot_main_coords,declare function={a=3;b=4;h=3;k=2;
            }] 
            \begin{scope}[canvas is xy plane at z=0]
                \path
                (0,0) coordinate (A) 
                (a,0) coordinate (B)
                (a,b) coordinate (C)
                (0,b) coordinate (D);
            \end{scope}
            \begin{scope}[canvas is xy plane at z=h]
                \path
                (0,k) coordinate (A') 
                (a,k) coordinate (B')
                (a,b+k) coordinate (C')
                (0,b+k) coordinate (D');
            \end{scope}  
            \begin{scope}[opacity=0.3,thick]
                \draw[fill=orange] (A) --(B)  -- (C) -- (D) -- cycle;
                \draw[fill=orange] (A) --(B)  -- (B') -- (A') -- cycle;
                \draw[fill=orange] (B) --(C)  -- (C') -- (B') -- cycle;
                \draw[fill=orange] (C) --(D)  -- (D') -- (C') -- cycle;
                \draw[fill=orange] (A) --(D)  -- (D') -- (A') --cycle;
                \draw[fill=orange] (A') --(B')  -- (C') -- (D') --cycle;
                \draw[-latex,line width=2pt] (B)--(A); % <<< added
                \draw[-latex,line width=2pt] (B)--(C); % <<< added
                \draw[-latex,line width=2pt] (B)--(B');% <<< added
            \end{scope}
        \end{tikzpicture}
    \end{document}

Output:

enter image description here

EDIT: But, perhaps, it's better like this:

enter image description here

Codu to change:

\begin{scope}[opacity=0.3,thick]
            \draw[fill=orange] (A) --(B)  -- (C) -- (D) -- cycle;
            \draw[fill=orange] (A) --(B)  -- (B') -- (A') -- cycle;
            \draw[fill=orange] (B) --(C)  -- (C') -- (B') -- cycle;
            \draw[fill=orange] (C) --(D)  -- (D') -- (C') -- cycle;
            \draw[fill=orange] (A) --(D)  -- (D') -- (A') --cycle;
            \draw[fill=orange] (A') --(B')  -- (C') -- (D') --cycle;
        \end{scope}
        \draw[-latex,line width=3pt] (D)--(A) node[left]() {$\vec{i}$}; % <<< added
        \draw[-latex,line width=3pt] (D)--(C) node[pos=1.1] () {$\vec{j}$};% <<< added
        \draw[-latex,line width=3pt] (D)--(D') node[pos=1.1] () {$\vec{k}$}; % <<< added
    \end{tikzpicture}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .