TransWikia.com

Adding label to a vector in a tikz figure

TeX - LaTeX Asked by Dimitris on December 30, 2020

I’ve found this post here:
graph of pendulum
and the nice answer of user @Torbjørn T.
I cannot figure out how to name the tension of the spring (blue vector).
I guess it will be below the line: draw [blue,-stealth] (bob) -- ($(bob)!Gcos cm!(centro)$); but I don’t know instruction to give. Thanks in advance for any help.

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] {$acostheta$};
    draw [-stealth] (bob) -- ($(bob)!Gsin cm!90:(centro)$)
      coordinate (gsin)
      node[midway,above left] {$asintheta$};
    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}

One Answer

enter image description here

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

Correct answer by js bibra on December 30, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP