我试图在线圈中绘制磁力线,它看起来应该是这样的这张照片使用tikz
包。我尝试使用foreach loop
带有控件的,但(也许我放置控件的位置不对)我没有得到类似力线的椭圆...我使用的代码是这个:
\begin{tikzpicture}
\tikzstyle arrowstyle=[scale=2] %Arrow size
\draw[thick, black, postaction={decorate,decoration={markings,mark=at position .42 with {\arrow[arrowstyle]{stealth}}}}] (0,0) ellipse (1 and 2);
\foreach \x in {0,0.5,...,5}
\draw (-3,\x) .. controls (0,0) and (0,0) .. (3,\x);
\end{tikzpicture}
我认为线条一定是椭圆的一部分,但我不知道如何放置这些椭圆的内点。
答案1
有更好的方法,例如极坐标图,但你可以从这样的方法开始:
\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{arrows.meta,decorations.markings}
\begin{document}
\begin{tikzpicture}
\tikzstyle arrowstyle=[scale=2] %Arrow size
\draw[thick, black, postaction={decorate,decoration={markings,mark=at position .42 with {\arrow[arrowstyle]{stealth}}}}] (0,0) ellipse (1 and 2);
\path[clip] (-2,-2.7) rectangle (2,2.7);
\foreach \y in {15,30,...,75} {
\draw (0,{2*tan(\y)+1.5*cos(\y)}) ellipse ({1.5*tan(\y)} and {2*tan(\y)});
\draw (0,{-2*tan(\y)-1.5*cos(\y)}) ellipse ({1.5*tan(\y)} and {2*tan(\y)});
}
\draw (-3,0) -- (3,0);
\end{tikzpicture}
\end{document}