我正在尝试绘制一个简单的图表,其中有角度的网格与平面相交。我有两个问题;
\begin{tikzpicture}
\filldraw[fill = blue!50!white, draw = black]
(2.2,-0.2) -- (3.8,-0.2) -- (3.8, 0.2) -- (2.2, 0.2) -- cycle; %Plane surface, centred on (3,0)
\draw[<-, line width = 1.6] (3,0) -- (140:3); %Incident wave vector
\foreach \y in {1, 2, 3, 4}
\draw[dotted] (3, 0.5*\y) -- (140:3);
\draw[->, line width = 1.6] (3,0) -- (3,2); %Normal-to-surface vector
\end{tikzpicture}
首先,该代码产生的是汇聚线而不是平行线(尽管指定了 140 度)我做错了什么?
其次,我该如何添加垂直指向但源自第一个 \draw 命令中定义的轴的线?
答案1
这些线不平行,因为你将它们绘制为(140:3)
而不是++(<angle>:3)
。可以使用 绘制正交线calc
。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\filldraw[fill = blue!50!white, draw = black]
(2.2,-0.2) -- (3.8,-0.2) -- (3.8, 0.2) -- (2.2, 0.2) -- cycle; %Plane surface, centred on (3,0)
\draw[<-, line width = 1.6] (3,0) coordinate (X)-- (140:3)
foreach \X [count=\Y] in {0.4,0.6,0.8,1} {coordinate[pos=\X] (p\Y)}; %Incident wave vector
\foreach \Y in {1,...,4}
{\draw[dotted] (p\Y) -- ($ (p\Y)!2cm!90:(X) $);}
\draw[dotted] let \p1=($(140:3)-(3,0)$),\n1={atan2(\y1,\x1)}
in foreach \y in {1, 2, 3, 4} {(3, 0.5*\y) -- ++(\n1:6)};
\draw[->, line width = 1.6] (3,0) -- (3,2); %Normal-to-surface vector
\end{tikzpicture}
\end{document}
Max 善意地指出你可能想要一些不同的东西:
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\filldraw[fill = blue!50!white, draw = black]
(2.2,-0.2) -- (3.8,-0.2) -- (3.8, 0.2) -- (2.2, 0.2) -- cycle; %Plane surface, centred on (3,0)
\draw[<-, line width = 1.6] (3,0) coordinate (X)-- (140:3)
foreach \X [count=\Y] in {0.2,0.4,0.6,0.8,1} {coordinate[pos=\X] (p\Y)}; %Incident wave vector
\foreach \Y in {1,...,5}
{\draw[dotted] (p\Y) -- ++ (0,2.5);}
\draw[dotted] let \p1=($(140:3)-(3,0)$),\n1={atan2(\y1,\x1)}
in foreach \y in {1, 2, 3, 4} {(3, 0.5*\y) -- ++(\n1:6)};
\draw[->, line width = 1.6] (3,0) -- (3,2); %Normal-to-surface vector
\end{tikzpicture}
\end{document}