我只是在思考这个问题

我只是在思考这个问题

我希望我的问题的解决方法不会太复杂或繁琐。我正在绘制一个图表,其中有一个麻烦:

在此处输入图片描述

每当正弦曲线接触轴时,TiKz 就会尝试绘制一条长度为 0 的线,因此它会在该位置产生箭头尖端

如何删除这些箭头,而不列出每一行(即使用类似\foeach \x in ...或类似的方法。因此基本上删除每个 180 倍数的箭头

在此处输入图片描述

以下是绘制该图的代码:

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc,patterns}
\usepackage{tikz-3dplot}
\usepackage[left=0.00cm, right=0.00cm]{geometry}
\usepackage{physics}
\usepackage{bm}
\usepackage{rotating}

%Defining Diagonal Arrows:
\newcommand{\neswarrow}{%
    \begin{turn}{45}
        \raisebox{-1ex}{$\leftrightarrow$}
    \end{turn}
}
\newcommand{\nwsearrow}{%
    \begin{turn}{45}
        \raisebox{0ex}{$\updownarrow$}
    \end{turn}
}
\begin{document}
        \tdplotsetmaincoords{75}{135}
\begin{tikzpicture}[tdplot_main_coords,scale=0.5]
\draw[red,very thick,-latex] plot[smooth,variable=\x,domain=0:720,samples=360] (-{2*sin(\x)},{\x*(2*3/360)},{2*sin(\x)});
\foreach \x in {45,90,...,720} { %LOOK HERE FOR FIRST SET OF ARROWS
    \draw[-latex,help lines,red] (0,{\x*(2*3/360},0) -- (-{2*sin(\x)},{\x*(2*3/360)},{2*sin(\x)});}
\draw[very thick,red,latex-latex,densely dashed] (-2,12,2) -- (2,12,-2);
\begin{scope}[canvas is xz plane at y=12,xscale=-1]
\draw[very thick,fill=white,fill opacity=0.6] (0,0) circle (3.5);
\node[anchor=south,transform shape,scale=1.5] at (0,3.5) {\large Polariser};
\draw[blue,pattern=north west lines, pattern color=blue] (0,0) --  (-90:1.5) arc (-90:-135:1.5) -- cycle;
\draw[blue] (-112.5:1.3) ..controls +(-112.5:0.7) and +(180:0.7).. (0.7,-1.7) node[right] {$\alpha$};
\end{scope}
\draw[very thick] (0,12,-3) -- (0,12,3);
\draw[red,very thick,-latex] plot[smooth,variable=\x,domain=720:1440,samples=360] (0,{\x*(2*3/360)},{2*sin(\x)});
\foreach \x in {720,765,...,1440} {%LOOK HERE FOR SECOND SET OF ARROWS
    \draw[-latex,help lines,red] (0,{\x*(2*3)/360},0) -- (0,{\x*(2*3/360)},{2*sin(\x)});}
\begin{scope}[canvas is xz plane at y=24,xscale=-1]
\draw[very thick,densely dashed,latex-latex,red] (-90:2) -- (90:2);
\end{scope}
\begin{scope}[canvas is xz plane at y=24,xscale=-1]
\draw[very thick,fill=white,fill opacity=0.6] (0,0) circle (3.5);
\draw[blue,pattern=north west lines, pattern color=blue] (0,0) --  (90:1) arc (90:30:1) -- cycle;
\node[blue] at (60:1.4) {$\theta$};
\draw[very thick] (-150:3) -- (30:3);
\node[anchor=south,transform shape,scale=1.5] at (90:3.5) {\large Analyser};
\end{scope}
\draw[red,very thick,-latex] plot[smooth,variable=\x,domain=1440:1800,samples=360] ({-0.7071067812*sin(\x)},{\x*(2*3/360)},{0.5*sin(\x)});
\foreach \x in {1440,1485,...,1800} { %LOOK HERE FOR THIRD SET OF ARROWS
    \draw[-latex,help lines,red] (0,{\x*(2*3)/360},0) -- ({-0.7071067812*sin(\x)},{\x*(2*3/360)},{0.5*sin(\x)});}
\draw[-latex] (0,0,0) -- (0,32,0);
\draw[-latex] (0,0,-3) -- (0,0,3);
\draw[-latex] (3,0,0) -- (-3,0,0);
\begin{scope}[canvas is xz plane at y=1.5,xscale=-1]
\draw[red] (2,2) .. controls +(45:0.5) and +(-120:0.5).. (3,2.7);
\end{scope}
\node[scale=0.75,red] at (-3,4,3.7) {$\bm{E}=A_{\neswarrow}\cos\left(2\pi f t+\phi_{\neswarrow}\right)\ket{\neswarrow}+0\ket{\nwsearrow}$};
\draw (0,12,-2.7) .. controls +(0:1) and +(-135:2).. (4,12,-3) node[below,scale=0.75] {Axis of Polarisation};
\begin{scope}[canvas is xz plane at y=16.5,xscale=-1]
\draw[red] (0,-2) .. controls +(-90:1) and +(0:0.5).. (-2,-4.4) node[left,scale=0.75] {$\bm{E}=A_{\neswarrow}\cos(\alpha)\cos\left(2\pi ft+\phi_{\neswarrow}\right)\ket{\updownarrow} + 0\ket{\leftrightarrow}$};
\end{scope}
\end{tikzpicture}
\tdplotsetmaincoords{0}{0}
\begin{tikzpicture}[remember picture,overlay]
\begin{scope}[xshift=-5.8cm,yshift=4cm]
\draw (1,1) circle (1.1);
\draw[red,thick,latex-latex] (0.5,0.5) -- (1.5,1.5);
\draw[thick] (1,0.25) -- (1,1.75);
\draw[red,densely dashed,thick] (1.5,1.5) -- (1,1.5) (1,0.5) -- (0.5,0.5);
\node[left,scale=0.6,red,fill=white] at (1,1.5) {$A_{\neswarrow}\cos(\alpha)$};
\draw[blue,pattern=north west lines,pattern color=blue] (1,1) -- +(45:0.25) arc (45:90:0.25) -- cycle;
\draw[blue] (1,1) +(67.5:0.2) ..controls +(45:0.3) and +(180:0.1).. (1.4,1) node[right] {$\alpha$};
\node[below,scale=0.75] at (1,-0.1) {Polariser};
\end{scope}
\begin{scope}[xshift=-0.8cm,yshift=4.1cm,rotate=-60]
\draw (0,0) circle (1.1);
\draw[red,thick,latex-latex] (150:0.7071067812) -- (-30:0.7071067812);
\draw[thick] (0,-0.75) -- (0,0.75);
\draw[red,densely dashed,thick] (150:0.7071067812) -- (0,0.3535533906) (0,-0.3535533906) -- (-30:0.7071067812);
\draw[blue,pattern=north west lines,pattern color=blue] (0,0) -- (150:0.25) arc (150:90:0.25) -- cycle;
\draw[blue] (120:0.2) ..controls +(120:0.3) and +(-90:0.1).. (-0.3,0.6) node[above right=-0.07cm] {$\theta$};
\node[below,scale=0.75] at (-30:1.1) {Analyser};
\end{scope}
\end{tikzpicture}
\end{document}

抱歉,代码太乱了,我使用 LaTeX 写代码的习惯很差。我注释了产生定义波浪的箭头的 3 行代码。

我只是在思考这个问题

我认为也许使用双栈\foreach是可行的。第一个是\a列表中的一些变量{45,225,405},然后在其下放置类似的东西,\foreach \x in {\A,\A+45,\A+90}{...}因此它看起来会像这样:

\foreach \a in {45,225,405} {
    \foreach \x in {{\a},{\a +45},{\a +90}}{
    \draw[-latex,help lines,red] (0,{\x*(2*3)/360},0) -- (0,{\x*(2*3/360)},{2*sin(\x)});
    }
}

对于第一组热线。

不幸的是,这次尝试对我来说不起作用

编辑:它确实有效(见下面的答案),但是有没有更有效或更简洁的方法来解决这个问题,一种不需要知道 0 尖箭头的位置就可以工作的方法(例如,如果它们是随机生成的)?

答案1

这是另一种选择。我不知道它是否更整洁。原则上,tips=on proper draw来自 pgfmanual 第 187 页,Paul Gaborit 指出这里,应该可以解决问题。但我无法做到这一点,所以我手动实现了长度检查。这可能在不太容易通过分析看出零长度路径出现的情况下更有用。

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc,patterns}
\usepackage{tikz-3dplot}
\usepackage[left=0.00cm, right=0.00cm]{geometry}
\usepackage{physics}
\usepackage{bm}
\usepackage{rotating}

%Defining Diagonal Arrows:
\newcommand{\neswarrow}{%
    \begin{turn}{45}
        \raisebox{-1ex}{$\leftrightarrow$}
    \end{turn}
}
\newcommand{\nwsearrow}{%
    \begin{turn}{45}
        \raisebox{0ex}{$\updownarrow$}
    \end{turn}
}
\begin{document}
        \tdplotsetmaincoords{75}{135}
\begin{tikzpicture}[tdplot_main_coords,scale=0.5]
\draw[red,very thick,-latex] plot[smooth,variable=\x,domain=0:720,samples=360] (-{2*sin(\x)},{\x*(2*3/360)},{2*sin(\x)});
\foreach \X in {45,90,...,720} { %LOOK HERE FOR FIRST SET OF ARROWS
    \path let \p1=($(0,{\X*(2*3/360},0) -
    (-{2*sin(\X)},{\X*(2*3/360)},{2*sin(\X)})$),\n1={veclen(\x1,\y1)} in 
    \pgfextra{\xdef\mylen{\n1}};
    \ifdim\mylen>1pt
    \draw[-latex,help lines,red] (0,{\X*(2*3/360},0) -- (-{2*sin(\X)},{\X*(2*3/360)},{2*sin(\X)});
    \fi
    }
\draw[very thick,red,latex-latex,densely dashed] (-2,12,2) -- (2,12,-2);
\begin{scope}[canvas is xz plane at y=12,xscale=-1]
\draw[very thick,fill=white,fill opacity=0.6] (0,0) circle (3.5);
\node[anchor=south,transform shape,scale=1.5] at (0,3.5) {\large Polariser};
\draw[blue,pattern=north west lines, pattern color=blue] (0,0) --  (-90:1.5) arc (-90:-135:1.5) -- cycle;
\draw[blue] (-112.5:1.3) ..controls +(-112.5:0.7) and +(180:0.7).. (0.7,-1.7) node[right] {$\alpha$};
\end{scope}
\draw[very thick] (0,12,-3) -- (0,12,3);
\draw[red,very thick,-latex] plot[smooth,variable=\x,domain=720:1440,samples=360] (0,{\x*(2*3/360)},{2*sin(\x)});
\foreach \X in {720,765,...,1440} {%LOOK HERE FOR SECOND SET OF ARROWS
    \path let \p1=($(0,{\X*(2*3)/360},0) - (0,{\X*(2*3/360)},{2*sin(\X)})$),
      \n1={veclen(\x1,\y1)} in  \pgfextra{\xdef\mylen{\n1}};
    \ifdim\mylen>1pt    
    \draw[-latex,help lines,red,] (0,{\X*(2*3)/360},0) -- (0,{\X*(2*3/360)},{2*sin(\X)});
    \fi}
\begin{scope}[canvas is xz plane at y=24,xscale=-1]
\draw[very thick,densely dashed,latex-latex,red] (-90:2) -- (90:2);
\end{scope}
\begin{scope}[canvas is xz plane at y=24,xscale=-1]
\draw[very thick,fill=white,fill opacity=0.6] (0,0) circle (3.5);
\draw[blue,pattern=north west lines, pattern color=blue] (0,0) --  (90:1) arc (90:30:1) -- cycle;
\node[blue] at (60:1.4) {$\theta$};
\draw[very thick] (-150:3) -- (30:3);
\node[anchor=south,transform shape,scale=1.5] at (90:3.5) {\large Analyser};
\end{scope}
\draw[red,very thick,-latex] plot[smooth,variable=\x,domain=1440:1800,samples=360] ({-0.7071067812*sin(\x)},{\x*(2*3/360)},{0.5*sin(\x)});
\foreach \X in {1440,1485,...,1800} { %LOOK HERE FOR THIRD SET OF ARROWS
    \path let \p1=($(0,{\X*(2*3)/360},0) -  ({-0.7071067812*sin(\X)},{\X*(2*3/360)},{0.5*sin(\X)})$),   
    \n1={veclen(\x1,\y1)} in    
    \pgfextra{\xdef\mylen{\n1}};
    \ifdim\mylen>1pt
    \draw[-latex,help lines,red] (0,{\X*(2*3)/360},0) -- ({-0.7071067812*sin(\X)},{\X*(2*3/360)},{0.5*sin(\X)});
    \fi}
\draw[-latex] (0,0,0) -- (0,32,0);
\draw[-latex] (0,0,-3) -- (0,0,3);
\draw[-latex] (3,0,0) -- (-3,0,0);
\begin{scope}[canvas is xz plane at y=1.5,xscale=-1]
\draw[red] (2,2) .. controls +(45:0.5) and +(-120:0.5).. (3,2.7);
\end{scope}
\node[scale=0.75,red] at (-3,4,3.7) {$\bm{E}=A_{\neswarrow}\cos\left(2\pi f t+\phi_{\neswarrow}\right)\ket{\neswarrow}+0\ket{\nwsearrow}$};
\draw (0,12,-2.7) .. controls +(0:1) and +(-135:2).. (4,12,-3) node[below,scale=0.75] {Axis of Polarisation};
\begin{scope}[canvas is xz plane at y=16.5,xscale=-1]
\draw[red] (0,-2) .. controls +(-90:1) and +(0:0.5).. (-2,-4.4) node[left,scale=0.75] {$\bm{E}=A_{\neswarrow}\cos(\alpha)\cos\left(2\pi ft+\phi_{\neswarrow}\right)\ket{\updownarrow} + 0\ket{\leftrightarrow}$};
\end{scope}
\end{tikzpicture}
\tdplotsetmaincoords{0}{0}
\begin{tikzpicture}[remember picture,overlay]
\begin{scope}[xshift=-5.8cm,yshift=4cm]
\draw (1,1) circle (1.1);
\draw[red,thick,latex-latex] (0.5,0.5) -- (1.5,1.5);
\draw[thick] (1,0.25) -- (1,1.75);
\draw[red,densely dashed,thick] (1.5,1.5) -- (1,1.5) (1,0.5) -- (0.5,0.5);
\node[left,scale=0.6,red,fill=white] at (1,1.5) {$A_{\neswarrow}\cos(\alpha)$};
\draw[blue,pattern=north west lines,pattern color=blue] (1,1) -- +(45:0.25) arc (45:90:0.25) -- cycle;
\draw[blue] (1,1) +(67.5:0.2) ..controls +(45:0.3) and +(180:0.1).. (1.4,1) node[right] {$\alpha$};
\node[below,scale=0.75] at (1,-0.1) {Polariser};
\end{scope}
\begin{scope}[xshift=-0.8cm,yshift=4.1cm,rotate=-60]
\draw (0,0) circle (1.1);
\draw[red,thick,latex-latex] (150:0.7071067812) -- (-30:0.7071067812);
\draw[thick] (0,-0.75) -- (0,0.75);
\draw[red,densely dashed,thick] (150:0.7071067812) -- (0,0.3535533906) (0,-0.3535533906) -- (-30:0.7071067812);
\draw[blue,pattern=north west lines,pattern color=blue] (0,0) -- (150:0.25) arc (150:90:0.25) -- cycle;
\draw[blue] (120:0.2) ..controls +(120:0.3) and +(-90:0.1).. (-0.3,0.6) node[above right=-0.07cm] {$\theta$};
\node[below,scale=0.75] at (-30:1.1) {Analyser};
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

\foreach在双层堆栈中使用 是可行的。本质上是这样的:

\foreach \a in {1485,1665} {
    \foreach \x in {{\a},(\a +45),(\a +90)}{
        \draw[-latex,help lines,red] (0,{\x*(2*3)/360},0) -- ({-0.7071067812*sin(\x)},{\x*(2*3/360)},{0.5*sin(\x)});
    }
}

最终的代码如下所示:

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc,patterns}
\usepackage{tikz-3dplot}
\usepackage[left=0.00cm, right=0.00cm]{geometry}
\usepackage{physics}
\usepackage{bm}
\usepackage{rotating}

%Defining Diagonal Arrows:
\newcommand{\neswarrow}{%
    \begin{turn}{45}
        \raisebox{-1ex}{$\leftrightarrow$}
    \end{turn}
}
\newcommand{\nwsearrow}{%
    \begin{turn}{45}
        \raisebox{0ex}{$\updownarrow$}
    \end{turn}
}
\begin{document}
        \tdplotsetmaincoords{75}{135}
\begin{tikzpicture}[tdplot_main_coords,scale=0.5]
\draw[red,very thick,-latex] plot[smooth,variable=\x,domain=0:720,samples=360] (-{2*sin(\x)},{\x*(2*3/360)},{2*sin(\x)});
\foreach \a in {45,225,405,585} {
    \foreach \x in {{\a},(\a +45),(\a +90)}{
        \draw[-latex,help lines,red] (0,{\x*(2*3)/360},0) -- ({-2*sin(\x)},{\x*(2*3/360)},{2*sin(\x)});
    }
}
\draw[very thick,red,latex-latex,densely dashed] (-2,12,2) -- (2,12,-2);
\begin{scope}[canvas is xz plane at y=12,xscale=-1]
\draw[very thick,fill=white,fill opacity=0.6] (0,0) circle (3.5);
\node[anchor=south,transform shape,scale=1.5] at (0,3.5) {\large Polariser};
\draw[blue,pattern=north west lines, pattern color=blue] (0,0) --  (-90:1.5) arc (-90:-135:1.5) -- cycle;
\draw[blue] (-112.5:1.3) ..controls +(-112.5:0.7) and +(180:0.7).. (0.7,-1.7) node[right] {$\alpha$};
\end{scope}
\draw[very thick] (0,12,-3) -- (0,12,3);
\draw[red,very thick,-latex] plot[smooth,variable=\x,domain=720:1440,samples=360] (0,{\x*(2*3/360)},{2*sin(\x)});
\foreach \a in {765,945,1125,1305} {
    \foreach \x in {{\a},(\a +45),(\a +90)}{
        \draw[-latex,help lines,red] (0,{\x*(2*3)/360},0) -- (0,{\x*(2*3/360)},{2*sin(\x)});
    }
}
\begin{scope}[canvas is xz plane at y=24,xscale=-1]
\draw[very thick,densely dashed,latex-latex,red] (-90:2) -- (90:2);
\end{scope}
\begin{scope}[canvas is xz plane at y=24,xscale=-1]
\draw[very thick,fill=white,fill opacity=0.6] (0,0) circle (3.5);
\draw[blue,pattern=north west lines, pattern color=blue] (0,0) --  (90:1) arc (90:30:1) -- cycle;
\node[blue] at (60:1.4) {$\theta$};
\draw[very thick] (-150:3) -- (30:3);
\node[anchor=south,transform shape,scale=1.5] at (90:3.5) {\large Analyser};
\end{scope}
\draw[red,very thick,-latex] plot[smooth,variable=\x,domain=1440:1800,samples=360] ({-0.7071067812*sin(\x)},{\x*(2*3/360)},{0.5*sin(\x)});
\foreach \a in {1485,1665} {
    \foreach \x in {{\a},(\a +45),(\a +90)}{
        \draw[-latex,help lines,red] (0,{\x*(2*3)/360},0) -- ({-0.7071067812*sin(\x)},{\x*(2*3/360)},{0.5*sin(\x)});
    }
}
\draw[-latex] (0,0,0) -- (0,32,0);
\draw[-latex] (0,0,-3) -- (0,0,3);
\draw[-latex] (3,0,0) -- (-3,0,0);
\begin{scope}[canvas is xz plane at y=1.5,xscale=-1]
\draw[red] (2,2) .. controls +(45:0.5) and +(-120:0.5).. (3,2.7);
\end{scope}
\node[scale=0.75,red] at (-3,4,3.7) {$\bm{E}=A_{\neswarrow}\cos\left(2\pi f t+\phi_{\neswarrow}\right)\ket{\neswarrow}+0\ket{\nwsearrow}$};
\draw (0,12,-2.7) .. controls +(0:1) and +(-135:2).. (4,12,-3) node[below,scale=0.75] {Axis of Polarisation};
\begin{scope}[canvas is xz plane at y=16.5,xscale=-1]
\draw[red] (0,-2) .. controls +(-90:1) and +(0:0.5).. (-2,-4.4) node[left,scale=0.75] {$\bm{E}=A_{\neswarrow}\cos(\alpha)\cos\left(2\pi ft+\phi_{\neswarrow}\right)\ket{\updownarrow} + 0\ket{\leftrightarrow}$};
\end{scope}
\end{tikzpicture}
\tdplotsetmaincoords{0}{0}
\begin{tikzpicture}[remember picture,overlay]
\begin{scope}[xshift=-5.8cm,yshift=4cm]
\draw (1,1) circle (1.1);
\draw[red,thick,latex-latex] (0.5,0.5) -- (1.5,1.5);
\draw[thick] (1,0.25) -- (1,1.75);
\draw[red,densely dashed,thick] (1.5,1.5) -- (1,1.5) (1,0.5) -- (0.5,0.5);
\node[left,scale=0.6,red,fill=white] at (1,1.5) {$A_{\neswarrow}\cos(\alpha)$};
\draw[blue,pattern=north west lines,pattern color=blue] (1,1) -- +(45:0.25) arc (45:90:0.25) -- cycle;
\draw[blue] (1,1) +(67.5:0.2) ..controls +(45:0.3) and +(180:0.1).. (1.4,1) node[right] {$\alpha$};
\node[below,scale=0.75] at (1,-0.1) {Polariser};
\end{scope}
\begin{scope}[xshift=-0.8cm,yshift=4.1cm,rotate=-60]
\draw (0,0) circle (1.1);
\draw[red,thick,latex-latex] (150:0.7071067812) -- (-30:0.7071067812);
\draw[thick] (0,-0.75) -- (0,0.75);
\draw[red,densely dashed,thick] (150:0.7071067812) -- (0,0.3535533906) (0,-0.3535533906) -- (-30:0.7071067812);
\draw[blue,pattern=north west lines,pattern color=blue] (0,0) -- (150:0.25) arc (150:90:0.25) -- cycle;
\draw[blue] (120:0.2) ..controls +(120:0.3) and +(-90:0.1).. (-0.3,0.6) node[above right=-0.07cm] {$\theta$};
\node[below,scale=0.75] at (-30:1.1) {Analyser};
\end{scope}
\end{tikzpicture}
\end{document}

这解决了我的问题:

在此处输入图片描述

仍然想知道是否有比我的解决方案更整洁、更简洁或更通用的解决方案?

答案3

我使用了tip= on proper draw@marmot 在他的回答中指出的密钥。

  • 第一个循环运行良好。
  • 但是对于另外两个,我必须重写坐标并除以 60,而不是乘以 6 然后除以 360,这样才能得到正确的结果。

代替:

 \draw[-latex,help lines,red] (0,{\x*(2*3)/360},0) -- (0,{\x*(2*3/360)},{2*sin(\x)});

我写的:

\draw[-latex,help lines,red,tips=on proper draw] (0,{\x/60},0) -- (0,{\x/60},{2*sin(\x)});

我认为这是一个与 TeX 计算方式有关的问题。

截屏

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc,patterns}
\usepackage{tikz-3dplot}
\usepackage[left=0.00cm, right=0.00cm]{geometry}
\usepackage{physics}
\usepackage{bm}
\usepackage{rotating}

%Defining Diagonal Arrows:
\newcommand{\neswarrow}{%
    \begin{turn}{45}
        \raisebox{-1ex}{$\leftrightarrow$}
    \end{turn}
}
\newcommand{\nwsearrow}{%
    \begin{turn}{45}
        \raisebox{0ex}{$\updownarrow$}
    \end{turn}
}
\begin{document}
        \tdplotsetmaincoords{75}{135}
\begin{tikzpicture}[tdplot_main_coords,scale=0.5]
\draw[red,very thick,-latex] plot[smooth,variable=\x,domain=0:720,samples=360] (-{2*sin(\x)},{\x*(2*3/360)},{2*sin(\x)});

\foreach \x in {45,90,...,720} { %LOOK HERE FOR FIRST SET OF ARROWS
    \draw[-latex,help lines,red,tips=on proper draw] (0,{\x*(2*3/360},0) -- (-{2*sin(\x)},{\x*(2*3/360)},{2*sin(\x)});}

\draw[very thick,red,latex-latex,densely dashed] (-2,12,2) -- (2,12,-2);
\begin{scope}[canvas is xz plane at y=12,xscale=-1]
\draw[very thick,fill=white,fill opacity=0.6] (0,0) circle (3.5);
\node[anchor=south,transform shape,scale=1.5] at (0,3.5) {\large Polariser};
\draw[blue,pattern=north west lines, pattern color=blue] (0,0) --  (-90:1.5) arc (-90:-135:1.5) -- cycle;
\draw[blue] (-112.5:1.3) ..controls +(-112.5:0.7) and +(180:0.7).. (0.7,-1.7) node[right] {$\alpha$};
\end{scope}
\draw[very thick] (0,12,-3) -- (0,12,3);
\draw[red,very thick,-latex] plot[smooth,variable=\x,domain=720:1440,samples=360] (0,{\x*(2*3/360)},{2*sin(\x)});

\foreach \x in {720,765,...,1440} {%LOOK HERE FOR SECOND SET OF ARROWS
    \draw[-latex,help lines,red,tips=on proper draw] (0,{\x/60},0) -- (0,{\x/60},{2*sin(\x)});}

\begin{scope}[canvas is xz plane at y=24,xscale=-1]
\draw[very thick,densely dashed,latex-latex,red] (-90:2) -- (90:2);
\end{scope}
\begin{scope}[canvas is xz plane at y=24,xscale=-1]
\draw[very thick,fill=white,fill opacity=0.6] (0,0) circle (3.5);
\draw[blue,pattern=north west lines, pattern color=blue] (0,0) --  (90:1) arc (90:30:1) -- cycle;
\node[blue] at (60:1.4) {$\theta$};
\draw[very thick] (-150:3) -- (30:3);
\node[anchor=south,transform shape,scale=1.5] at (90:3.5) {\large Analyser};
\end{scope}
\draw[red,very thick,-latex] plot[smooth,variable=\x,domain=1440:1800,samples=360] ({-0.7071067812*sin(\x)},{\x*(2*3/360)},{0.5*sin(\x)});

\foreach \x in {1440,1485,...,1800} { %LOOK HERE FOR THIRD SET OF ARROWS
    \draw[-latex,help lines,red,tips=on proper draw] (0,{\x*(2*3)/360},0) -- ({-0.7071067812*sin(\x)},{\x/60},{0.5*sin(\x)});}

\draw[-latex] (0,0,0) -- (0,32,0);
\draw[-latex] (0,0,-3) -- (0,0,3);
\draw[-latex] (3,0,0) -- (-3,0,0);
\begin{scope}[canvas is xz plane at y=1.5,xscale=-1]
\draw[red] (2,2) .. controls +(45:0.5) and +(-120:0.5).. (3,2.7);
\end{scope}
\node[scale=0.75,red] at (-3,4,3.7) {$\bm{E}=A_{\neswarrow}\cos\left(2\pi f t+\phi_{\neswarrow}\right)\ket{\neswarrow}+0\ket{\nwsearrow}$};
\draw (0,12,-2.7) .. controls +(0:1) and +(-135:2).. (4,12,-3) node[below,scale=0.75] {Axis of Polarisation};
\begin{scope}[canvas is xz plane at y=16.5,xscale=-1]
\draw[red] (0,-2) .. controls +(-90:1) and +(0:0.5).. (-2,-4.4) node[left,scale=0.75] {$\bm{E}=A_{\neswarrow}\cos(\alpha)\cos\left(2\pi ft+\phi_{\neswarrow}\right)\ket{\updownarrow} + 0\ket{\leftrightarrow}$};
\end{scope}
\end{tikzpicture}
\tdplotsetmaincoords{0}{0}
\begin{tikzpicture}[remember picture,overlay]
\begin{scope}[xshift=-5.8cm,yshift=4cm]
\draw (1,1) circle (1.1);
\draw[red,thick,latex-latex] (0.5,0.5) -- (1.5,1.5);
\draw[thick] (1,0.25) -- (1,1.75);
\draw[red,densely dashed,thick] (1.5,1.5) -- (1,1.5) (1,0.5) -- (0.5,0.5);
\node[left,scale=0.6,red,fill=white] at (1,1.5) {$A_{\neswarrow}\cos(\alpha)$};
\draw[blue,pattern=north west lines,pattern color=blue] (1,1) -- +(45:0.25) arc (45:90:0.25) -- cycle;
\draw[blue] (1,1) +(67.5:0.2) ..controls +(45:0.3) and +(180:0.1).. (1.4,1) node[right] {$\alpha$};
\node[below,scale=0.75] at (1,-0.1) {Polariser};
\end{scope}
\begin{scope}[xshift=-0.8cm,yshift=4.1cm,rotate=-60]
\draw (0,0) circle (1.1);
\draw[red,thick,latex-latex] (150:0.7071067812) -- (-30:0.7071067812);
\draw[thick] (0,-0.75) -- (0,0.75);
\draw[red,densely dashed,thick] (150:0.7071067812) -- (0,0.3535533906) (0,-0.3535533906) -- (-30:0.7071067812);
\draw[blue,pattern=north west lines,pattern color=blue] (0,0) -- (150:0.25) arc (150:90:0.25) -- cycle;
\draw[blue] (120:0.2) ..controls +(120:0.3) and +(-90:0.1).. (-0.3,0.6) node[above right=-0.07cm] {$\theta$};
\node[below,scale=0.75] at (-30:1.1) {Analyser};
\end{scope}
\end{tikzpicture}
\end{document}

答案4

您可以使用xintexpr它,但\foreach在您的上下文中嵌套肯定更自然。

\edef\mylist{\xinttheiiexpr seq((x/:180)?{x}{omit}, x = 45..[45]..720)\relax}
\foreach \x in \mylist { %LOOK HERE FOR FIRST SET OF ARROWS
    \draw[-latex,help lines,red] (0,{\x*(2*3/360},0) -- (-{2*sin(\x)},{\x*(2*3/360)},{2*sin(\x)});}

解释:x/:180是余数,我们要消除它为零的情况,这就是?运算符和omit关键字的作用。当然还有45..[45]..720等差数列生成器。

可以使用\xintFor语法,但它只会扩展一次列表参数,因此需要这样做:

\xintFor #1 in {\romannumeral-`0\xintiieval{seq((x/:180)?{x}{omit}, x = 45..[45]..720)}}:
{ %LOOK HERE FOR FIRST SET OF ARROWS
    \draw[-latex,help lines,red] (0,{#1*(2*3/360},0) -- (-{2*sin(#1)},{#1*(2*3/360)},{2*sin(#1)});
}

需要\xintiievalxint 1.3d。否则在末尾使用\xinttheiiexpr、无括号和。\relax

正如我所说,这只是因为下午下雨。双人\foreach避免了额外的包裹......

在此处输入图片描述

相关内容