在 tikz 图形中向矢量添加标签

在 tikz 图形中向矢量添加标签

我在这里找到了这个帖子: 钟摆图 以及用户@Torbjørn T 的精彩回答。我不知道如何命名弹簧的张力(蓝色矢量)。我猜它会在线下:\draw [blue,-stealth] (bob) -- ($(bob)!\Gcos cm!(centro)$);但我不知道该给出什么说明。提前感谢任何帮助。

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc,patterns,angles,quotes}
\begin{document}
\begin{tikzpicture}
    % save length of g-vector and theta to macros
    \pgfmathsetmacro{\Gvec}{1.5}
    \pgfmathsetmacro{\myAngle}{30}
    % calculate lengths of vector components
    \pgfmathsetmacro{\Gcos}{\Gvec*cos(\myAngle)}
    \pgfmathsetmacro{\Gsin}{\Gvec*sin(\myAngle)}

    \coordinate (centro) at (0,0);
    \draw[dashed,gray,-] (centro) -- ++ (0,-3.5) node (mary) [black,below]{$ $};
    \draw[thick] (centro) -- ++(270+\myAngle:3) coordinate (bob);
    \pic [draw, ->, "$\theta$", angle eccentricity=1.5] {angle = mary--centro--bob};
    \draw [blue,-stealth] (bob) -- ($(bob)!\Gcos cm!(centro)$);
    \draw [-stealth] (bob) -- ($(bob)!-\Gcos cm!(centro)$)
      coordinate (gcos)
      node[midway,above right] {$a\cos\theta$};
    \draw [-stealth] (bob) -- ($(bob)!\Gsin cm!90:(centro)$)
      coordinate (gsin)
      node[midway,above left] {$a\sin\theta$};
    \draw [-stealth] (bob) -- ++(0,-\Gvec)
      coordinate (g)
      node[near end,left] {$g$};
    \pic [draw, ->, "$\theta$", angle eccentricity=1.5] {angle = g--bob--gcos};
    \filldraw [fill=black!40,draw=black] (bob) circle[radius=0.1];
\end{tikzpicture}
\end{document}

答案1

在此处输入图片描述

\draw [blue,-stealth] (bob) -- ($(bob)!\Gcos cm!(centro)$)node[right,pos=0.5, color=black, font=\scriptsize](){$a$};

相关内容