箭头指向错误方向的问题

箭头指向错误方向的问题

我是 TeX 和 TiKz 库的新手,目前正在制作一个倾斜平面的图像,其中有一个箭头从文本点指向平面的倾斜部分。但是,我遇到了一些困难,代码似乎没有按预期工作。

这是我目前拥有的代码:

\documentclass{report}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[font=\small]
\draw [thick] (0,0) -- (6,0) -- (0,3) -- cycle;
\draw [thick, rotate around={-27:(0,3)}, shift={(0,3.25)}] (0.5,-0.25) rectangle (1,0.25);
\draw [<->, dashed] (-0.25,-0) -- (-0.25,3);
\node [left] at (-0.25,1.5) {$h$};

% Draw a horizontal line on the base of the plane
\draw [ultra thick] (6,0) -- (10,0);

% Add the label "Rough horizontal plane" below the line
\node [below] at (8,-0.7) {Rough horizontal plane};

% Draw an arrow from the label pointing to the line
\draw [->, thick] (8,-0.8) -- (8,0);

% Add the label "Smooth inclined plane" rotated like the inclined plane
\node [rotate=-27] at (4,2.5) {Smooth inclined plane};

% Calculate the coordinates of the hypotenuse of the triangle
\coordinate (A) at (6,0);
\coordinate (B) at (0,3);
\coordinate (C) at (0,0);
\coordinate (H) at ($(C)!(A)!(B)$);

% Calculate the intersection point between the arrow and the hypotenuse
\coordinate (I) at ($(4,2.5)!(H)!(6,0)$);

% Draw an arrow from the label pointing to the hypotenuse of the triangle
\draw [->, thick] (4,2.5) -- (I);
\end{tikzpicture}
\end{document}

此外,我还附加了当前输出的图像以供参考。

在此处输入图片描述

我将非常感激任何帮助或指导,以解决问题并改善形象。提前感谢您的帮助!

答案1

您的代码中可以进行许多调整以使其更高效并且绘图看起来更好,但您要求一件事,它就在这里。

我建议在线 AB 上放置一个点 H,然后将节点放在正确的位置(距离 H 1 厘米且直角)。

箭

\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}[font=\small]
\draw [thick] (0,0) -- (6,0) -- (0,3) -- cycle;
\draw [thick, rotate around={-27:(0,3)}, shift={(0,3.25)}] (0.5,-0.25) rectangle (1,0.25);
\draw [<->, dashed] (-0.25,-0) -- (-0.25,3);
\node [left] at (-0.25,1.5) {$h$};

% Draw a horizontal line on the base of the plane
\draw [ultra thick] (6,0) -- (10,0);

% Add the label "Rough horizontal plane" below the line
\node [below] at (8,-0.7) {Rough horizontal plane};

% Draw an arrow from the label pointing to the line
\draw [->, thick] (8,-0.8) -- (8,0);

\coordinate (A) at (6,0);
\coordinate (B) at (0,3);
\coordinate (C) at (0,0);

% Put H on the middle of line AB
\coordinate (H) at ($(B)!0.5!(A)$);

% Add the label "Smooth inclined plane" rotated like the inclined plane and at 1 cm and at right angle from H
\node [rotate=-27,inner sep=1pt] (I) at ($ (H)!1cm!-90:(B) $) {Smooth inclined plane};

% Draw an arrow from the label pointing to the hypotenuse of the triangle
\draw [->, thick] (I) -- (H);
\end{tikzpicture}
\end{document}

相关内容