我正在尝试为我的物理课绘制一个斜面自由体图(有点像这里的图片):
目前,我的代码如下所示(使用 TikZ、tkz-euclide、TiKz 库 calc 和 plotmarks):
\begin{tikzpicture}[scale=0.8, transform shape] %incline plane
%triangle coordinates
\coordinate (A) at (0,0);
\coordinate (B) at (7,0);
\coordinate (C) at (0,5);
%box coordinates
\coordinate (D) at ($(C)!3/8!(B)$);
\coordinate (E) at ($(C)!5/8!(B)$);
\coordinate [label=below:$F$](F) at ($(C)!1/2!(B)$);
\coordinate (G) at ($(E)!1!-90:(F)$);
\coordinate (H) at ($(D)!1!90:(F)$);
\coordinate (I) at ($(F)!1!90:(E)$);
\coordinate [label=above:$J$](J) at ($(F)!1/2!(I)$);
%vector coordinates
\coordinate [label=left:$K$] (K) at ($(A)!1/4!(C)$);
\draw (D) -- (E) -- (G) -- (H) -- cycle;
\draw (F) -- (J);
\draw (F) -- (K);
\path plot[mark=*] coordinates {(J)};
%draw and label triangle
\tkzDrawPolygon(A,B,C)
\tkzMarkAngle(C,B,A)
\tkzLabelAngle[left,pos=1](C,B,A){$\theta$}
\tkzMarkRightAngle(C,A,B)
\end{tikzpicture}
其结果如下:
我如何计算出一个由 F 和 K 组成直角三角形的点,以便我可以从 J(盒子中心的点)开始,绘制一个沿着三角形 3/4 路径(矢量 m*g)向下的矢量?
答案1
我可能没有正确理解要求,但是这样吗?
\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=0.8, transform shape] %incline plane
%triangle coordinates
\coordinate (A) at (0,0);
\coordinate (B) at (7,0);
\coordinate (C) at (0,5);
%box coordinates
\coordinate (D) at ($(C)!3/8!(B)$);
\coordinate (E) at ($(C)!5/8!(B)$);
\coordinate (F) at ($(C)!1/2!(B)$);
\coordinate (G) at ($(E)!1!-90:(F)$);
\coordinate (H) at ($(D)!1!90:(F)$);
\coordinate (I) at ($(F)!1!90:(E)$);
\coordinate [label=above:$J$](J) at ($(F)!1/2!(I)$);
%vector coordinates
\coordinate [label=left:$K$] (K) at ($(A)!1/4!(C)$);
\draw (D) -- (E) -- (G) -- (H) -- cycle;
\draw (F) -- (J);
\draw (F) -- (K);
\path plot[mark=*] coordinates {(J)};
\coordinate (L) at ($(G)!1/2!(E)$); %% <--- added
\draw[-latex] (J) -- (L); %% <--- added
\draw[-latex] (J) -- (K-|J)node[below]{$mg$}; %% <--- added
%draw and label triangle
\tkzDrawPolygon(A,B,C)
\tkzMarkAngle(C,B,A)
\tkzLabelAngle[left,pos=1](C,B,A){$\theta$}
\tkzMarkRightAngle(C,A,B)
\end{tikzpicture}
\end{document}
对于评论中的疑问,您可以这样做
%------ added -----------------
\coordinate (L) at ($(G)!1/2!(E)$);
\coordinate (M) at (K-|J);
\path
let \p1 = ($(J) - (M) $),
\n1 = {veclen(\x1,\y1)}
in
coordinate (N) at ($(J)!0.9*\n1!(L)$); %% change 0.9*\n1 as you wish, \n1 is length of mg
\draw[-latex] (J) -- (N);
\draw[-latex] (J) -- (M)node[below]{$mg$};
\tkzMarkAngle[size=4mm](M,J,N)
\tkzLabelAngle[below,pos=0.4](N,J,M){$\alpha$}
%----- upto here ---------------