图 2 交叉梯子问题

图 2 交叉梯子问题

我想绘制如下三角形:

在此处输入图片描述

但使用以下代码会产生:

在此处输入图片描述

代码必须表示三角形的结构,如下所示:\documentclass[tikz,border=2pt]{standalone} \usetikzlibrary{intersections,arrows.meta} \usepackage{siunitx}

    \begin{document}

    \begin{tikzpicture}
      \draw   (0,0) -- (5,0) -- (5,5) -- (5.5,5);
      \draw[name path=A] (0,0)coordinate(o) -- (5,4.5)node[pos=0.8,sloped,auto]{$l_2=\SI{10}{\meter}$};
      \draw[name path=B] (0,3) -- (5,0)node[pos=0.1,sloped,auto]{};
      \path[name intersections={of=A and B,by={a}}];
      \draw[dashed] (a)node[right=1mm]{M} -- (a|-o)node[pos=0.7,auto]{$R=\SI{3}{\meter}$}
              coordinate[pos=1](a);
      \coordinate (o) at (0,-0.5);
      \draw[|<->|] (0,-0.5) -- node[below]{$d_1$} (a|-o);
      \draw[|<->|] (0,-1) -- node[below]{$d$} (5,-1);
      \draw[|<->|] (5.5,0) -- node[right]{$R_2$} (5.5,4.5);
    \end{tikzpicture}

    \end{document}

所以我无法管理任何帮助将不胜感激

答案1

使用\path代替\draw不应该绘制的“梯子”:

在此处输入图片描述

\documentclass[tikz,border=2pt]{standalone}
\usetikzlibrary{intersections,arrows.meta}
\usepackage{siunitx}

\begin{document}

    \begin{tikzpicture}
      \draw   (0,0) -- (5,0) -- (5,5) -- (5.5,5);
      \draw[name path=A] (0,0)coordinate(o) -- (5,4.5)node[pos=0.8,sloped,auto]{$l_2=\SI{10}{\meter}$};
      \path[name path=B] (0,3) -- (5,0)node[pos=0.1,sloped,auto]{};
      \path[name intersections={of=A and B,by={a}}];
      \draw[dashed] (a)node[right=1mm]{M} -- (a|-o)node[pos=0.7,auto]{$R=\SI{3}{\meter}$}
              coordinate[pos=1](a);
      \coordinate (o) at (0,-0.5);
      \draw[|<->|] (0,-0.5) -- node[below]{$d_1$} (a|-o);
      \draw[|<->|] (0,-1) -- node[below]{$d$} (5,-1);
      \draw[|<->|] (5.5,0) -- node[right]{$R_2$} (5.5,4.5);
    \end{tikzpicture}

\end{document}

相关内容