![在 Tikz 中以透视方式绘制机场跑道](https://linux22.com/image/416979/%E5%9C%A8%20Tikz%20%E4%B8%AD%E4%BB%A5%E9%80%8F%E8%A7%86%E6%96%B9%E5%BC%8F%E7%BB%98%E5%88%B6%E6%9C%BA%E5%9C%BA%E8%B7%91%E9%81%93.png)
我正在尝试在 TikZ 中生成带有标记和轻微透视的机场跑道。我使用 for 循环获得的解决方案似乎相当复杂且不太清晰。
有没有一种有效的方法可以将跑道标记画成斜线?也许,先将所有东西画成平面,然后倾斜整个图形?
这是 MWE,用倾斜的标记绘制跑道!
\documentclass[tikz,margin=1mm,border=1mm]{standalone}
\usetikzlibrary{arrows,calc,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[line width=1pt]
%% Runway plot
% Runway outer boundaries
\draw[-] (0,-0.5) -- (+15,-0.5) -- (+15.5,-1) -- (+0.5,-1) -- cycle;
% Center line
%\draw[dashed,dash pattern=on 15pt off 5pt,line width=1.5pt] (+0.5,-0.75) -- (+15,-0.75);
\foreach \i in {1,...,24}
{
\pgfmathtruncatemacro{\x}{\i * 0.6};
\draw[-,fill] (\x+0.375,-0.73) --++ (15pt,0) --++ (0.25pt,-0.25pt) --++ (-15pt,0) -- cycle;
}
% Threshold
\draw[-,fill] (0.25,-0.6) --++ (15pt,0) --++ (1.5pt,-1.5pt) --++ (-15pt,0) -- cycle;
\draw[-,fill] (0.5,-0.85) --++ (15pt,0) --++ (1.5pt,-1.5pt) --++ (-15pt,0) -- cycle;
\draw[-,fill] (14.4,-0.6) --++ (15pt,0) --++ (1.5pt,-1.5pt) --++ (-15pt,0) -- cycle;
\draw[-,fill] (14.65,-0.85) --++ (15pt,0) --++ (1.5pt,-1.5pt) --++ (-15pt,0) -- cycle;
\end{tikzpicture}
\end{document}
感谢您的帮助
罗曼
答案1
你可以照常绘图:
然后使用该xslant
选项获取倾斜的图片。
完整代码:
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[xslant=-.8]
\def\a{15.5}
\def\step{5mm}
\draw[thick] (0,0) rectangle (\a,1);
\draw[dashed,dash pattern=on \step off \step] (.5,.5)--(\a-.5,.5);
\fill
(.5,.7) rectangle +(\step,.1)
(.5,.3) rectangle +(\step,-.1)
(\a-.5,.7) rectangle +(-\step,.1)
(\a-.5,.3) rectangle +(-\step,-.1);
\end{tikzpicture}
\end{document}
答案2
使用该库的解决方案3d
:
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3d}
\begin{document}
\begin{tikzpicture}[canvas is xz plane at y=0]
\coordinate (s) at (0,0);
\coordinate (f) at (15.3,0);
\draw ([yshift=-1cm]s) rectangle ([yshift=1cm]f);
\draw[dash pattern=on 3mm off 2mm,dash phase=3mm,very thick,gray] ([xshift=3mm]s) -- ([xshift=-3mm]f);
\fill ([shift={(3mm,3mm)}]s) rectangle +(4mm,2mm);
\fill ([shift={(3mm,-3mm)}]s) rectangle +(4mm,-2mm);
\fill ([shift={(-3mm,3mm)}]f) rectangle +(-4mm,2mm);
\fill ([shift={(-3mm,-3mm)}]f) rectangle +(-4mm,-2mm);
\end{tikzpicture}
\end{document}