I would like to draw this image in Latex.
Here the arrows inside the ellipse represent dipoles. They are polarized by the magnetic field $B$. $d$ is the distance between the two ellipses.
I would like to draw this image in Latex.
Here the arrows inside the ellipse represent dipoles. They are polarized by the magnetic field $B$. $d$ is the distance between the two ellipses.
Welcome to TeX.SE! The purpose of this site is to exchange codes and to ask for help if one is stuck with some LaTeX problem. This usually does not include asking others to translate a screen shot to LaTeX code. However, for newcomers sometimes exceptions are made.
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d,shapes.geometric,shadows.blur}
% small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
\makeatletter
\tikzoption{canvas is xy plane at z}[]{%
\def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
\def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
\def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
\tikz@canvas@is@plane}
\makeatother
\begin{document}
\tdplotsetmaincoords{60}{130}
\begin{tikzpicture}[tdplot_main_coords,>=latex,line join=bevel]
\coordinate (O) at (0,0,0);
\draw[thick,->] (O) -- (5,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (O) -- (0,5,0) node[anchor=north west]{$y$};
\draw[thick,->] (O) -- (0,0,5) node[anchor=south]{$z$};
\draw[dashed] (O) -- (-5,0,0);
\begin{scope}[canvas is yz plane at x=5,transform shape]
\node[ellipse,fill=blue,fill opacity=0.7,draw,minimum width=2cm,minimum height=8mm,
rotate=65] (elliL) at (2,2) {};
\path (elliL.west) -- (elliL.east) coordinate[pos=0.1] (L1b)
coordinate[pos=0.3] (L1t) coordinate[pos=0.4] (L2b)
coordinate[pos=0.6] (L2t) coordinate[pos=0.7] (L3b)
coordinate[pos=0.9] (L3t);
\foreach \X in {1,2,3}
{\draw[thick,-latex] (L\X b) -- (L\X t);}
\end{scope}
\begin{scope}[canvas is yz plane at x=-1,transform shape]
\node[ellipse,fill=blue,fill opacity=0.7,draw,minimum width=2cm,minimum height=8mm,
rotate=80] (elliR) at (2,2) {};
\path (elliR.west) -- (elliR.east) coordinate[pos=0.1] (R1b)
coordinate[pos=0.3] (R1t) coordinate[pos=0.4] (R2b)
coordinate[pos=0.6] (R2t) coordinate[pos=0.7] (R3b)
coordinate[pos=0.9] (R3t);
\foreach \X in {1,2,3}
{\draw[thick,-latex] (R\X b) -- (R\X t);}
\end{scope}
% this is essentially from the tikz-3dplot manual p. 26-27
\pgfmathsetmacro{\rvec}{7}
\pgfmathsetmacro{\thetavec}{30}
\pgfmathsetmacro{\phivec}{60}
\tdplotsetcoord{P}{\rvec}{\thetavec}{\phivec}
\node[anchor=south west,color=red] at (P) {$B$};
\draw[-stealth,color=red,very thick] (O) -- (P);
\draw[dashed, color=red] (O) -- (Pxy);
\draw[dashed, color=red] (P) -- (Pxy);
\tdplotdrawarc{(O)}{1}{0}{\phivec}{anchor=north}{$\phi$}
\tdplotsetthetaplanecoords{\phivec}
\tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{1.5}{0}%
{\thetavec}{anchor=-110}{$\theta$}
%
\begin{scope}[canvas is xy plane at z=0,blue!70]
\path (5,2) -- (-1,2) node[midway,below] {$d$};
\pgflowlevelsynccm% not necessary but maybe nicer
\draw[ultra thick,latex-latex] (5,2) -- (-1,2);
\end{scope}
\end{tikzpicture}
\end{document}
I personally would not like to depend on others, the more so playing with these codes can be fun. Therefore, I'd like to encourage you to try to figure out what's going on here.
canvas is yx plane at z instead of canvas is xy plane at z (cf. https://tex.stackexchange.com/a/367560)
– Henri Menke
Nov 18 '18 at 01:41
xy plane might actually be deliberate: https://sourceforge.net/p/pgf/bugs/410/
– Henri Menke
Nov 18 '18 at 01:48
rotate=90, xscale=-1 and so on. However, I guess there is only one person who will ultimately be able to clarify this. A compromise might be to just add another library to CTAN with a slightly different syntax. Some days I think that this together with these macros might be useful for some.
–
Nov 18 '18 at 02:10