如何绘制圆极化电磁波

如何绘制圆极化电磁波

我正在寻找一种解决方案,以便在我的乳胶文档中获得美观的圆偏振波。我的目标是得到一个如下所示的图表:

在此处输入图片描述

我不希望图表有动画,但我甚至无法让它绘制圆形波浪。

任何帮助都将非常感激。

答案1

可能是这样的吗?不确定是否正确。

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[x={(0.75cm,.5cm)}, z={(1cm,-.25cm)}]

\tikzset{%
    xyz path/.style args={\x=#1; \y=#2; \z=#3; (#4)}{
        insert path={
            \foreach \step [evaluate={\x=#1; \y=#2; \z=#3;}] in {#4}{   
                -- (\x, \y, \z) } 
        }
    },
    cosine path/.style args={#1:#2}{
        xyz path={\x=cos(\step); \y=0; \z=\step/360; (#1, 5, ..., #2)},
        insert path={ coordinate (cosine path end) }
    },
    sine path/.style args={#1:#2}{
        xyz path={\x=0; \y=sin(\step); \z=\step/360; (#1, 5, ..., #2)},
        insert path={ coordinate (sine path end) }
    },
    spiral path/.style args={#1:#2}{
        xyz path={\x=cos(\step); \y=sin(\step); \z=\step/360; (#1, 5, ..., #2)},
        insert path={ coordinate (spiral path end) }
    },
    marker/.style={
        insert path={
            node [fill, circle,  inner sep=0pt, minimum size=#1] {}
        }
    }
}

\def\lastangle{135}
\def\cycles{5}

\foreach \cycle in {0,...,\cycles}{
    \tikzset{shift={(0, 0, \cycle)}}
    \ifnum\cycle=\cycles
        \let\endangle=\lastangle
    \else
        \def\endangle{360}
    \fi
    \draw [red] (1, 0, 0) [cosine path={0:\endangle}];
    \draw [green] (0, 0, 0) [sine path={0:\endangle}];
    \draw [blue, very thick] (1, 0, 0) [spiral path={0:\endangle}];
}

\tikzset{shift={(0,0,\cycles+\lastangle/360)}}

\draw [dotted, thick]
    (-2,-2, 0) -- (2,-2,0) -- (2,2,0) -- (-2,2,0) -- cycle
    (0,-2) -- (0,2) (-2,0) -- (2,0) 
    (1, 0) 
    \foreach \step [evaluate={\y=sin(\step); \x=cos(\step);}] in {0, 5, ..., 355}{  
            -- (\x, \y, 0) } ;

\draw [orange] (cosine path end) -- (spiral path end) -- (sine path end);
\draw [red] (0,0,0) -- (cosine path end) [marker=2pt];
\draw [green] (0,0,0) -- (sine path end) [marker=2pt];
\draw [blue, very thick] (0,0,0) -- (spiral path end) [marker=4pt];
\end{tikzpicture}

\end{document}          

在此处输入图片描述

编辑当然我们可以做得更好:

\documentclass{standalone}
\usepackage[active,tightpage]{preview}
\usepackage{tikz}
\PreviewEnvironment{tikzpicture}
\usetikzlibrary{backgrounds}
\begin{document}

\tikzset{%
    calculate step/.code=\pgfmathsetmacro\step{#1+5},
    cosine path/.style args={#1:#2}{
        insert path={ [calculate step=#1]
            (cos #1, 0, #1/360)  
            \foreach \t in {#1, \step, ..., #2}{ -- (cos \t, 0, \t/360) }
            coordinate (cosine path end) 
        }
    },
    sine path/.style args={#1:#2}{
        insert path={ [calculate step=#1]
            (0, sin #1, #1/360)  
            \foreach \t in {#1, \step, ..., #2}{ -- (0, sin \t, \t/360) }  
            coordinate (sine path end) 
        }
    },
    spiral path/.style args={#1:#2}{
        insert path={ [calculate step=#1]
            (cos #1, sin #1, #1/360)  
            \foreach \t in {#1,\step, ..., #2}{ -- (cos \t, sin \t, \t/360) }  
            coordinate (spiral path end) 
        },
    },
    marker/.style={
        insert path={
            node [fill, circle,  inner sep=0pt, minimum size=#1] {}
        }
    },
    background/.style={
        background rectangle/.style={fill=black}, 
        show background rectangle
    },
    cosine/.style={
        red
    },
    sine/.style={
        green
    },
    spiral/.style={
        cyan,
        very thick
    },
    indicator/.style={
        orange
    },
    grid/.style={
        white,
        loosely dotted,
        thick
    },
    axis/.style={
        white,
        thick
    }
}

\def\cycles{4}

\foreach \phase in {0, 10, ..., 350}{%
\begin{tikzpicture}[x={(0.75cm, .5cm)}, z={(1cm, -.25cm)}, 
    background, 
    line cap=round
]
\draw [axis] (0, 0, \phase/360) -- (0, 0, \cycles+\phase/360);
\foreach \cycle in {0,...,\cycles}{
    \tikzset{shift={(0, 0, \cycle)}}
    \ifnum\cycle=0
        \let\startangle=\phase
    \else
        \def\startangle{0}
    \fi
    \ifnum\cycle=\cycles
        \let\endangle=\phase
    \else
        \def\endangle{360}
    \fi
    \draw [cosine] [cosine path={\startangle:\endangle}];
    \draw [sine]   [sine path={\startangle:\endangle}];
    \draw [spiral] [spiral path={\startangle:\endangle}];
}

\begin{scope}[shift={(0, 0, \cycles+\phase/360)}]

\draw [grid]
    (-2, -2, 0) -- (2, -2, 0) -- (2, 2, 0) -- (-2, 2, 0) -- cycle
    (0, -2) -- (0, 2) (-2, 0) -- (2, 0) 
    (1, 0) \foreach \t in {0, 5, ..., 355}{ -- (cos \t, sin \t, 0) };

\draw [indicator] (cosine path end) -- (spiral path end) -- (sine path end);
\draw [cosine]    (0, 0, 0) -- (cosine path end) [marker=2pt];
\draw [sine]      (0, 0, 0) -- (sine path end)   [marker=2pt];
\draw [spiral]    (0, 0, 0) -- (spiral path end) [marker=4pt];

\end{scope}

\useasboundingbox 
    [shift={(0, 0, \phase/360)}]
    (-1.125, -1.125, 0) -- (1.125, -1.125, 0) -- 
    (1.125, 1.125, 0) -- (-1.125, 1.125, 0) -- cycle
    [shift={(0, 0, \cycles)}]
    (-2.125, -2.125, 0) -- (2.125, -2.125,0) -- 
    (2.125, 2.125, 0) -- (-2.125, 2.125, 0) -- cycle;
\end{tikzpicture}}
\end{document}

在此处输入图片描述

请注意,在上面的代码生成的 PDF 中,螺旋是向后旋转的,因此当 Gimp 生成动画时,它会朝另一个方向旋转。

相关内容