1

I am trying to illustrate something like this using tikz or pstricks.

I almost have what I want, which is essentially a 3 dimensional object spanned by the vector.

I would like to add faces that look like the picture I have below, and I would like to know how to add the angle theta as well.

thank you

\documentclass{article}

\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage[pdftex,active,tightpage]{preview}
\setlength\PreviewBorder{2mm}



\begin{document}
\begin{preview}

\tdplotsetmaincoords{50}{110}
\begin{tikzpicture}[tdplot_main_coords]
\draw[thick,->, dashed, gray] (0,0,0) -- (3,0,0) node[anchor=north east]{$x$};
\draw[thick,->, dashed] (0,0,0) -- (0,3,0) node[anchor=north west]{$y$};
\draw[thick,->, dashed] (0,0,0) -- (0,0,3) node[anchor=south]{$z$};
\pgfmathsetmacro{\bx}{-1}
\pgfmathsetmacro{\by}{3}
\pgfmathsetmacro{\bz}{0}
\pgfmathsetmacro{\ax}{1}
\pgfmathsetmacro{\ay}{4}
\pgfmathsetmacro{\az}{0}
\pgfmathsetmacro{\cx}{3}
\pgfmathsetmacro{\cy}{5}
\pgfmathsetmacro{\cz}{5}


\tdplotcrossprod(\ax,\ay,\az)(\bx,\by,\bz)
\draw[->,red] (0,0,0) -- (\ax,\ay,\az) node[anchor=west]{$\vec{A}=[\ax, \ay, \az]$};
\draw[dashed, ->,red] (\bx,\by,\bz) -- (\bx+\ax,\by+\ay,\bz+\az) node[anchor=west]{ };

\draw[->,green!50!black] (0,0,0) -- (\bx,\by,\bz) node[anchor=north west]{$\vec{B}=[\bx,\by,\bz]$};
\draw[dashed, ->,brown!50!black] (0,0,0) -- (\cx,\cy,\cz) node[anchor=south west]{$\vec{C}=[\cx,\cy,\cz]$};


\draw[->,green!50!black] (0,0,0) -- (\bx,\by,\bz) node[anchor=north west]{$\vec{B}=[\bx,\by,\bz]$};


\draw[dashed, ->,gray,fill=blue, opacity=.14] (0,0,0) -- (\ax,\ay,\az) -- (\ax+\bx,\ay+\by,\az+\bz) -- (\bx,\by,\bz) -- (0,0,0);


\draw[->,blue] (0,0,0) -- (\tdplotresx,\tdplotresy,\tdplotresz) node[anchor=south east]{$\vec{A}\times\vec{B}$};
%\draw[dashed,blue] (0,0,0) -- (\tdplotresx,\tdplotresy,0) -- (\tdplotresx,\tdplotresy,\tdplotresz);
\end{tikzpicture}


\end{preview}
\end{document}

enter image description here

any help is much appreciated

5
  • Hi ! Do you begin some code ?
    – flav
    Feb 1, 2016 at 17:24
  • thx @flav I just added my code.
    – userX
    Feb 1, 2016 at 18:21
  • Your result is kind of different from the other image. I mean, there are extra lines, etc. Do you simply want the "cube" preserving the rest?
    – Alenanno
    Feb 1, 2016 at 18:31
  • @Alenanno yes, I just want to draw the rest of the cube, small variances are ok.. also I want to redo the face I made because it looks really flat. The desired pictures appears to have more depth
    – userX
    Feb 1, 2016 at 18:33
  • I don't really understand the relationship between the diagram you're working on and the target image.
    – cfr
    Feb 1, 2016 at 22:17

1 Answer 1

4

A little late with the answer, I know. I'm just practicing with Tikz.

\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usepackage{amsmath}
\usetikzlibrary{decorations.pathreplacing,calligraphy,shapes.multipart}

\begin{document}
\tdplotsetmaincoords{60}{85}
\begin{tikzpicture}[tdplot_main_coords]

% vectors coordinates
\pgfmathsetmacro{\bx}{-1}
\pgfmathsetmacro{\by}{3}
\pgfmathsetmacro{\bz}{0}
\pgfmathsetmacro{\ax}{1}
\pgfmathsetmacro{\ay}{4}
\pgfmathsetmacro{\az}{0}
\pgfmathsetmacro{\cx}{1}
\pgfmathsetmacro{\cy}{3}
\pgfmathsetmacro{\cz}{5}

% origin and other vertexes
\coordinate (O) at (0,0,0);
\coordinate (A) at (\ax,\ay,\az);
\coordinate (B) at (\bx,\by,\bz);
\coordinate (C) at (\cx,\cy,\cz);
\coordinate (AB) at (\ax+\bx,\ay+\by,\az+\bz);
\coordinate (AC) at (\ax+\cx,\ay+\cy,\az+\cz);
\coordinate (BC) at (\bx+\cx,\by+\cy,\bz+\cz);
\coordinate (ABC) at (\ax+\bx+\cx,\ay+\by+\cy,\az+\bz+\cz);

% axes
\begin{scope}[every path/.style={thick,->, dashed, gray}]
    \draw (O) -- (3,0,0) node[anchor=north east]{$x$};
    \draw (O) -- (0,3,0) node[anchor=west]{$y$};
    \draw (O) -- (0,0,3) node[anchor=south west]{$z$};
\end{scope}

% vectors
\draw[->,ultra thick,red] (O) -- (A) node[anchor=north west]{$\vec{A}=[\ax, \ay, \az]$};
\draw[dashed,->,red] (B) -- (AB);
\draw[->,ultra thick,green!50!black] (O) -- (B) node[anchor=south west]{$\vec{B}=[\bx,\by,\bz]$};
\draw[dashed,->,green!50!black] (A) -- (AB);
\draw[->,ultra thick,brown!50!black] (O) -- (C) node[anchor=south]{$\vec{C}=[\cx,\cy,\cz]$};

% angle theta
\tdplotgetpolarcoords{\cx}{\cy}{\cz}
\tdplotsetthetaplanecoords{\tdplotresphi}
\tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{1}{0}%
{\tdplotrestheta}{anchor=south}{$\theta$}

% faces
\begin{scope}[every path/.style={dashed, ->,draw=gray,fill=blue}]
    \draw[opacity=.10] (O) -- (A) -- (AB) -- (B) -- cycle;
    \draw[opacity=.20] (O) -- (C) -- (BC) -- (B) -- cycle;
    \draw[opacity=.15] (O) -- (A) -- (AC) -- (C) -- cycle;
    \draw[opacity=.01] (C) -- (AC) -- (ABC) -- (BC) -- cycle;
    \draw[opacity=.20] (A) -- (AC) -- (ABC) -- (AB) -- cycle;
    \draw[opacity=.10] (B) -- (BC) -- (ABC) -- (AB) -- cycle;
\end{scope}

% vector product
\tdplotcrossprod(\ax,\ay,\az)(\bx,\by,\bz)
\draw[->,blue] (O) -- (\tdplotresx,\tdplotresy,\tdplotresz) node[anchor=south east]{$\vec{A}\times\vec{B}$};

% projection of C onto z-axis
\draw[dashed] (0,0,\cz) -- (C);
\draw (0.08*\cx,0.08*\cy,\cz) -- +(0,0,-0.35) -- +(-0.08*\cx,-0.08*\cy,-0.35);

% calligraphic brace
\draw[decoration={calligraphic brace,amplitude=8pt,raise=4pt},decorate] (O) -- node[left=12pt] {$h$} (0,0,\cz);

% annotation
\draw (0,6,0) -- (2,8,0) node[anchor=north,align=center]{Area of base \\ $\lVert\vec{A}\times\vec{B}\rVert$};
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

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