I'm working on my Master degree final project and I need some images to illustrate the images method with a magnetic dipole. This is what I have for now:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{
calc,
decorations.pathreplacing
}
%
\newcommand\pgfmathsinandcos[3]{
\pgfmathsetmacro#1{sin(#3)}
\pgfmathsetmacro#2{cos(#3)}
}
\newcommand\LongitudePlane[3][current plane]{
\pgfmathsinandcos\sinEl\cosEl{#2} % elevation
\pgfmathsinandcos\sint\cost{#3} % azimuth
\tikzset{#1/.style={cm={\cost,\sint*\sinEl,0,\cosEl,(0,0)}}}
}
\newcommand\LatitudePlane[3][current plane]{
\pgfmathsinandcos\sinEl\cosEl{#2} % elevation
\pgfmathsinandcos\sint\cost{#3} % latitude
\pgfmathsetmacro\yshift{\cosEl*\sint}
\tikzset{#1/.style={cm={\cost,0,0,\cost*\sinEl,(0,\yshift)}}} %
}
\newcommand\DrawLongitudeCircle[2][1]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
% angle of "visibility"
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
\draw[current plane,color=black!100] (\angVis:1) arc (\angVis:\angVis+180:1);
\draw[current plane,dashed,color=black!100] (\angVis-180:1) arc (\angVis-180:\angVis:1);
}
\newcommand\DrawLatitudeCircle[2][1]{
\LatitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
\pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
% angle of "visibility"
\pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
\draw[current plane,color=black!100] (\angVis:1) arc (\angVis:-\angVis-180:1);
\draw[current plane,dashed,color=black!100] (180-\angVis:1) arc (180-\angVis:\angVis:1);
}
\begin{document}
\begin{tikzpicture}[scale=1,
interface/.style={postaction={draw, decorate, decoration={border,angle=45, amplitude=-3mm, segment length=2mm}}}
]
% \def\R{0.8} % sphere radius
\def\angEl{30} % elevation angle
\def\angAz{30} % azimuth angle
% \pgfmathsetmacro\H{\R*cos(\angEl)} % Distance to north pole
\LongitudePlane[xzplane]{\angEl}{\angAz} % x-axis plane
\def\ang{60}
\def\L{13mm}
\coordinate (O) at (0,0);
\node at (3,1.25) (Pr) {-};
\node at ($(Pr)+(\ang:\L/2)$) (mur){};
\node at (3,-1.25) (Pi) {-};
\node at ($(Pi)+(-\ang:\L/2)$) (mui){};
% \coordinate (O) at (0,0);
\fill[gray!10, rounded corners=2pt] (-3,-0.2) rectangle (5,0.2);
\draw[black,line width=.5pt,interface](-3,0)--(5,0);
\draw (O) node[xshift=-2mm, yshift=2mm] {$x_{0}$};
\draw [line width=1pt] (O) -- (1,0) node (y) {};
\filldraw[fill=white, line width=1pt] (1,0) circle(0.9mm) node[xshift=2mm, yshift=2mm]{$y_{0}$};
\draw[line width=1pt] (O) -- (0,1);
\filldraw[fill=white, line width=1pt] (0,1) circle(0.9mm) node[xshift=-2mm, yshift=2mm]{$z_{0}$};
\node at (-2,0.75) {Real};
\node at (-2,-0.75) [yshift=-1mm] {Image};
% Real
\draw[gray](O) -- ($(Pr)+(\ang:\L/2)$) node[midway, above]{${r}$};
\draw ($(Pr)+(\ang:\L/2)$) node[left] {$x$};
\draw [line width=0.5pt] ($(Pr)+(\ang:\L/2)$) -- ++(\ang-90:1);
\filldraw[fill=white, line width=0.5pt] ($(Pr)+(\ang:\L/2)+(\ang-90:1)$) circle(0.9mm) node[right]{$y$};
\draw[line width=0.5pt] ($(Pr)+(\ang:\L/2)$) -- ++(\ang:1);
\filldraw[fill=white, line width=0.5pt] ($(Pr)+(\ang:\L/2)+(\ang:1)$) circle(0.9mm) node[above]{$z$};
\draw[->, >=stealth, ultra thick, shorten >=1mm] (Pr) -- ++(\ang:\L) node (Pr2)[xshift=1mm, yshift=1mm]{+};
\draw[very thin] ($(mur)+({2.5mm*cos(90)},{2.5mm*sin(90)})$) arc (90:\ang:2.5mm);
\draw[very thin, ->] ($(mur)+({2.5mm*cos(150)},{2.5mm*sin(150)})$) arc (150:90:2.5mm) node [xshift=-1.5mm, yshift=1.5mm] {$\theta$};
\node at ($(Pr)+(\ang:\L/2)$) [xshift=3mm] {${\mu}$};
\filldraw[fill=white,line width=0.5pt]($(Pr)+(\ang:\L/2)$)circle(0.9mm);
\filldraw[fill=black,line width=0.25pt]($(Pr)+(\ang:\L/2)$)circle(.25mm);
% Image
\draw[gray](O) -- ($(Pi)+(-\ang:\L/2)$) node[midway, below]{${r^{\prime}}$};
\draw ($(Pi)+(-\ang:\L/2)$) node[left] {$x^{\prime}$};
\draw [line width=0.5pt] ($(Pi)+(-\ang:\L/2)$) -- ++(-\ang+90:1);
\filldraw[fill=white, line width=0.5pt] ($(Pi)+(-\ang:\L/2)+(-\ang+90:1)$) circle(0.9mm) node[xshift=3mm, yshift=1mm]{$y^{\prime}$};
\draw[line width=0.5pt] ($(Pi)+(-\ang:\L/2)$) -- ++(-\ang:1);
\filldraw[fill=white, line width=0.5pt] ($(Pi)+(-\ang:\L/2)+(-\ang:1)$) circle(0.9mm) node[xshift=2mm, yshift=-2mm]{$z^{\prime}$};
\draw[->, >=stealth, ultra thick, shorten >=1mm] (Pi) -- ++(-\ang:\L) node (Pi2)[xshift=1mm, yshift=-1mm]{+};
\draw[very thin] ($(mui)+({2.5mm*cos(-90)},{2.5mm*sin(-90)})$) arc (-90:-\ang:2.5mm);
\draw[very thin, ->] ($(mui)+({2.5mm*cos(-150)},{2.5mm*sin(-150)})$) arc (-150:-90:2.5mm) node [xshift=-1.5mm, yshift=-1.5mm] {$\theta$};
\node at ($(Pi)+(-\ang:\L/2)$) [xshift=3.5mm] {${\mu^{\prime}}$};
\filldraw[fill=white,line width=0.5pt]($(Pi)+(-\ang:\L/2)$)circle(0.9mm);
\filldraw[fill=black,line width=0.25pt]($(Pi)+(-\ang:\L/2)$)circle(.25mm);
% Projection
\draw[dashed, very thin] (mur) -- ($(O)!(mur)!(y)$) node[below](mux) {};
\draw[ultra thin] (mur) -- ($(mur)+(0,0.4)$);
\draw[dashed, very thin] (mui) -- ($(O)!(mui)!(y)$);
\draw[ultra thin] (mui) -- ($(mui)+(0,-0.4)$);
\filldraw[fill=white,line width=1pt](O)circle(0.9mm);
\filldraw[fill=black,line width=0.5pt](O)circle(.25mm);
% Field lines
\begin{scope}
[rotate around={\ang+90:(O)},
field line/.style={color=red!75!gray, smooth,
variable=\t, samples at={0,5,...,360}}
]
\newcommand{\fieldlinecurve}[2]{{(pow(#1,2)*(3*cos(#2)+cos(3*#2))}, {(pow(#1,2))*(sin(#2)+sin(3*#2))}}
% Longitudinal planes
\foreach \u in {0}{
\LongitudePlane[{{\u}zplane}]{\angEl}{\u}
\foreach \r in {0.1,0.2,...,0.6} {
\draw[{{\u}zplane}, field line, smooth]
plot (\fieldlinecurve{\r}{\t});
}
}
\end{scope}
\end{tikzpicture}
\end{document}
I've added at the origin of coordinates the field lines modified from the example: http://www.texample.net/tikz/examples/dipolar-magnetic-field/ but I don't know how really this function works to plot the lines, so I can't understand how to move it to the center of the dipoles.
Could it be possible to move the field lines to both dipoles and compress the lines near to the horizontal plane to get anything like the next image?