如何在 tikz 中绘制这个棱柱?

如何在 tikz 中绘制这个棱柱?

我正在尝试在 tikz 中重新创建该图像。

棱镜

答案1

这是一个开始:

\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{angles}
\usetikzlibrary{intersections}

\begin{document}
\begin{tikzpicture}
% geometry
\newcommand{\triangleWidth}{8cm}
\newcommand{\triangleHeight}{10cm}
\newcommand{\angleTheta}{40}
\newcommand{\arrowOutsideLength}{2cm}
\newcommand{\continuationLength}{2.5cm}
\newcommand{\auxLength}{2cm}
\show\auxLength

% style
\tikzset{
    triangle/.style={},
    arrow/.style={->, red},
    continuation/.style={dotted},
    aux/.style={gray},
    angle/.style={draw, angle radius=2em, angle eccentricity=1.5, pic text=#1},
    label at angle/.style={angle radius=1.5em, angle eccentricity=1, pic text=#1},
}

% coordinates
\coordinate (B);
\coordinate (bottom-left) at ($(B) + (-\triangleWidth/2,-\triangleHeight)$);
\coordinate (bottom-right) at ($(B) + (\triangleWidth/2,-\triangleHeight)$);
\coordinate (A) at ($(bottom-left)!.5!(B)$);
\coordinate (C) at ($(bottom-right)!.5!(B)$);

\coordinate (arrow-start) at ([shift=(180+\angleTheta/2:\arrowOutsideLength)] A);
\coordinate (continuation-end-A) at ([shift=(180+\angleTheta/2:-\continuationLength)] A);
\coordinate (aux-start-A) at ([shift=(180-\angleTheta/2:\auxLength/2)] A);
\coordinate (aux-end-A) at ([shift=(180-\angleTheta/2:-\auxLength/2)] A);

\coordinate (arrow-end) at ([shift=(-\angleTheta/2:\arrowOutsideLength)] C);
\coordinate (continuation-end-C) at ([shift=(-\angleTheta/2:-\continuationLength)] C);
\coordinate (aux-start-C) at ([shift=(\angleTheta/2:-\auxLength/2)] C);
\coordinate (aux-end-C) at ([shift=(\angleTheta/2:\auxLength/2)] C);

% draw
\draw[triangle] (bottom-left) -- (B) -- (bottom-right) -- cycle;
\draw[arrow] (arrow-start) -- (A) -- (C) -- (arrow-end);
\draw[continuation, name path=continuation-A] (A) -- (continuation-end-A);
\draw[continuation, name path=continuation-C] (C) -- (continuation-end-C);
\draw[aux] (aux-start-A) -- (aux-end-A);
\draw[aux] (aux-start-C) -- (aux-end-C);
\path [name intersections={of=continuation-A and continuation-C}] (intersection-1) coordinate (D);

% angles
\draw pic[angle=$\Phi$] {angle=A--B--C};
\draw pic[angle=$\theta$] {angle=aux-start-A--A--arrow-start};
\draw pic[angle=$\theta$] {angle=arrow-end--C--aux-end-C};

% node
\draw pic[label at angle=$B$] {angle=C--B--A};
\draw pic[label at angle=$A$] {angle=B--A--aux-start-A};
\draw pic[label at angle=$C$] {angle=aux-end-C--C--B};
\draw pic[label at angle=$D$] {angle=C--D--A};
\end{tikzpicture}
\end{document}

截屏

编辑:关于红色箭头,你可能对装饰库感兴趣(见tikz 文档第577-604页)。例如:

\usetikzlibrary{decorations.shapes}
arrow/.style={red, postaction={draw, decorate, decoration=triangles}},

屏幕截图 三角形 装饰

相关内容