3

I need help with some vector in Tikz. I don't know how to put the place the angle between B and v!

It should look like this (without the fat yellow q+ bobble):

Vector graphic

Here is what I have tried:

\documentclass[border=10pt, tikz]{standalone}
\usetikzlibrary{calc,intersections} %,quotes,angles doesn't work

\begin{document}
\begin{tikzpicture}
\coordinate (start) at (0,0) {};
\coordinate (A) at (0,5) node [above of=A, yshift=-20pt] {$\vec{q} (\vec{v} \vec{B})$};
\coordinate (B) at ($(A)+(-20:3)$) node [above of=B, yshift=-20pt] {$\vec{q} \vec{E}$};
\draw[->] (0,0) -- (A);
\draw[->] (0,0) -- (B);
\draw[->,red] (0,0) -- ($(0,0)!0.3333!(B)$) node [right, yshift=-5pt] {$\vec{E}$};
\draw[->] (0,0) -- (4,1) node [right] (F) {$\vec{B}$};
\draw[->] (0,0) -- (2.5,-.5) node [right] (G) {$\vec{v}$};
%\draw pic["$\alpha$", draw=orange, <->, angle eccentricity=1.2, angle radius=1cm]
    {angle=start--F--G};
\end{tikzpicture}
\end{document}

Kind regards and thank you very much in advance!

Amelie B. Blackstone
  • 1,502
  • 1
  • 13
  • 26
  • Strictly spoken this is the force on a charge in two EM fields, only the magnetic contribution is called Lorentz force ;-) (Off-topic comment, cfr would call it stickler to the rules ;-)) –  Jul 01 '15 at 13:55
  • @ChristianHupfer yeah, you are right ;-) ... I just called it a Lorentz force diagram, because it's the Lorentz force I want to take a deeper look on ;-) ... but you are right: the diagram shows the Lorenzt force on a charged particle in motion (velocity, v). And with an E and a B field with space and time variation :-) – Amelie B. Blackstone Jul 01 '15 at 14:06

3 Answers3

3

If you are using calc library, you can use the fraction syntax

\draw (a) -- ($(a)!0.3333!(b)$);

to draw one third of the way from a towards b.

Also have a look at Difference between "right of=" and "right=of" in PGF/TikZ to avoid the syntax left of which is still supported for compatibility reasons. The best practice is to use positioning library.

percusse
  • 157,807
1

You can use the let .. in syntax to calculate (A)+(B) or use the calc syntax with ($(A)+(B)$).

% Option 1
\draw[violet,->] let \p1 = (A) , \p2 = (B) in (0,0) -- (\x1+\x2,\y1+\y2) coordinate (A+B);
% Option 2
\draw[violet,->] (0,0) -- ($(A)+(B)$) coordinate (A+B);

If some libraries “don't work” may be there's something wrong with your installation.

Here's the full picture:

\documentclass[border=10pt, tikz]{standalone}
\usetikzlibrary{calc,arrows.meta,angles,bending,quotes}

\renewcommand*\vec{\mathbf}

\begin{document}
\begin{tikzpicture}[ultra thick,>={Triangle[angle=30:4pt 4]}]
  \coordinate (O) at (0,0);
  \coordinate[label=180:{$q (\vec{v} \times \vec{B})$}] (qvB) at (0,5);
  \coordinate[label=0:{$q \vec{E}$}] (qE) at ($(qvB)+(-20:3)$);
  \coordinate[label=45:{$\vec{F}$}] (F) at ($(qvB)+(qE)$);
  \coordinate[label=0:{$\vec{E}$}] (E) at ($(O)!0.45!(qE)$);
  \coordinate[label=0:{$\vec{B}$}] (B) at (4,1);
  \coordinate[label=0:{$\vec{v}$}] (v) at (2.5,-.5);
  \draw[thin,blue] (qvB) -- (F) -- (qE);
  \draw[->,blue] (O) -- (qvB);
  \draw[->,blue] (O) -- (qE);
  \draw[->,violet] (O) -- (F);
  \draw[->,green!70!black] (O) -- (E);
  \draw[->,green!70!black] (O) -- (B);
  \draw[->,orange] (O) -- (v);
  \pic[thick,draw,->,angle radius=1.7cm,angle eccentricity=1.2,"$\theta$"] {angle=v--O--B};
  \node[fill=orange!80!yellow,circle,fill] at (O) {$+q$};
\end{tikzpicture}
\end{document}

enter image description here

Manuel
  • 27,118
1

Thank you for all the great answers. Here is the result:

\documentclass[border=10pt, tikz]{standalone}
\usetikzlibrary{calc,intersections} %,quotes,angles doesn't work

\begin{document}
\begin{tikzpicture}
\coordinate (start) at (0,0) {};
\coordinate (A) at (0,5) node [above of=A, yshift=-20pt] {$\vec{q} (\vec{v} \vec{B})$};
\coordinate (B) at ($(A)+(-20:3)$) node [above of=B, yshift=-20pt] {$\vec{q} \vec{E}$};
\draw[->] (0,0) -- (A);
\draw[->] (0,0) -- (B);
\draw[->] (0,0) -- ($(A)+(B)$) coordinate (C) node [above,xshift=2pt] {$\vec{F}$};
\draw[gray,dashed] (A) -- (C) -- (B);
\draw[->,red] (0,0) -- ($(0,0)!0.3333!(B)$) node [right, yshift=-5pt] {$\vec{E}$};
\draw[->] (0,0) -- (4,1) coordinate (B2) node[right] {$\vec{B}$};
\draw[->] (0,0) -- (2.5,-.5) coordinate (v) node [right] (G) {$\vec{v}$};
\path[clip] (start) -- (B2) -- (v);
\fill[red, opacity=0.5, draw=black] (start) circle (5mm) node [right, black, xshift=15 pt, opacity=1,yshift=0.5pt] {$\theta$};
\node [black] at ($(start)+(30:7mm)$) {$\theta$};
\end{tikzpicture}
\end{document}

Vector.

Amelie B. Blackstone
  • 1,502
  • 1
  • 13
  • 26