1

I am new to TikZ and am working on a FBD, using relative points. I would like to add new x,y-axes to every new change in direction. I have tried something similar to what's found here: Projectile Motion Diagram using PGFplots/tikz?

However, this doesn't seem to work for relative points (I could of course be missing something that's obvious).

\documentclass{article}

\usepackage{tikz}

\usepackage{pgfplots}

\usetikzlibrary{scopes}

\begin{document}

\def\fangle{148}

\def\llangle{38}

\def\ulangle{185}

\def\ubangle{31}

\def\flength{1.6cm}

\def\lllength{3.5cm}

\def\ullength{3.8cm}

\def\ublength{5.6cm}

\begin{tikzpicture}[

    % force lines
    force/.style={>=latex,draw=blue,fill=blue},

    % axis lines
    axis/.style={densely dashed,gray,font=\small},

    % foot
    F/.style={thick}

    % lower leg
    LL/.style={thick}

    % upper leg
    UL/.style={thick}

    % upper body
    UB/.style={thick}
]
    
\draw[blue,line width=2pt] (0,0) -- (\fangle:\flength) -- ++ (\llangle:\lllength) -- ++ (\ulangle:\ullength) -- ++ (\ubangle:\ublength);

%\draw[axis,->] (0,0) -- (1,0);


\end{tikzpicture}

\end{document}

Edit 2: I tried changing the points to coordinates using relative coordinates, so I could then put the axes off the coordinate points. However, nothing appears, even though the typeset was successful.

\coordinate (O) at (0,0);

\coordinate (F) at (O) -- ++ (\fangle:\flength);

\coordinate (LL) at (F) -- ++ (\llangle:\lllength); 

\coordinate (UL) at (LL) -- ++ (\ulangle:\ullength);

\coordinate (UB) at (UL) -- ++ (\ubangle:\ublength);


\draw[blue, line width = 2pt] (O) -- ++ (F) -- ++ (LL) -- ++ (UL) -- ++ (UB);

Edit 3: This works to name the coordinates. However, now I need to figure out how to use them to add the axes to each change in direction. The FBD will look something like the picture, found below. So help with how to label, etc would be much appreciated as well! Though, I believe I will be able to figure that out, once I can get the axes to work.

\draw[blue,line width=2pt] (0,0) coordinate (O) node[red]{.} -- ++ (\fangle:\flength) coordinate (F) node[red]{.} -- ++ (\llangle:\lllength) coordinate (LL) node[red]{.} -- ++ (\ulangle:\ullength) coordinate (UL) node[red]{.} -- ++ (\ubangle:\ublength) coordinate (UB)node[red]{.};
2
  • Could you provide a thumbnail for you expected results?
    – Tom
    May 21, 2022 at 23:44
  • Hi Tom, I added a link to a google doc above with a quick mock up. Thank you!
    – EngK
    May 21, 2022 at 23:57

1 Answer 1

0

Welcome to TeX.SE!

As starting point .... I left to finish image to you :-)

\documentclass[margin=3mm]{standalone}
\usepackage{siunitx}                    % new
\usepackage{tikz}
\usetikzlibrary{angles, arrows.meta,    % new
                quotes,                 % new
                scopes} % where is needed?

\begin{document}

\def\fangle{148}
\def\llangle{38}
\def\ulangle{185}
\def\ubangle{31}
\def\flength{1.6cm}
\def\lllength{3.5cm}
\def\ullength{3.8cm}
\def\ublength{5.6cm}

\begin{tikzpicture}[auto=right,
every edge quotes/.append style = {font=\footnotesize},
my angle/.style = {draw, densely dotted,
                   angle radius = 5mm,
                   angle eccentricity=1.4,
                   font=\tiny},
        > = Latex,    % new
% force, vertical
Fv/.style = {->, draw=#1, thick}, % changed
    % axis lines
    axis/.style={densely dashed,gray,font=\small},
    % foot
    F/.style={thick}
    % lower leg
    LL/.style={thick}
    % upper leg
    UL/.style={thick}
    % upper body
    UB/.style={thick}
                    ]

\draw[blue,line width=2pt] 
    (0,0) coordinate (S)
          -- ++ (\fangle:\flength/2)      coordinate (Am)
          -- ++ (\fangle:\flength/2)      coordinate (A)
          -- ++ (\llangle:\lllength/2)    coordinate (Bm)
          -- ++ (\llangle:\lllength/2)    coordinate (B)
          -- ++ (\ulangle:\ullength/2)    coordinate (Cm)
          -- ++ (\ulangle:\ullength/2)    coordinate (C)
          -- ++ (\ubangle:\ublength/2)    coordinate (Dm)
          -- ++ (\ubangle:\ublength/2)    coordinate (D);
% "axis" /dashed lines)
\draw[axis] (-3,0) coordinate (aux) -- (aux -| D);
\draw[axis] (aux |- A) -- (A -| D) coordinate (Ad);
\draw[axis] (aux |- B) -- (B -| D);
\draw[axis] (aux |- C) -- (C -| D);
\draw[axis] (aux |- Dm) coordinate (Dam) -- (Dm -| D);
% angles
\pic [my angle, "\ang{148}"]    {angle = A--S--aux};
\pic [my angle, "\ang{38}"]     {angle = Ad--A--B};
\pic [my angle, "\ang{5}"]      {angle = C--B--A};
\pic [my angle, "\ang{31}"]     {angle = B--C--D};
% forces
\draw[Fv=brown]  (S)  to["$F_N$"] ++ (0,+0.8);
\draw[Fv=blue]   (Am) to["$W_F$"] ++ (0,-0.8);
\draw[Fv=purple] (Bm) to["$W_{LL}$" '] ++ (0,-0.8);
\draw[Fv=orange] (Cm) to["$W_{UL}$"]   ++ (0,-0.8);
\draw[Fv=red]    (Dm) to["$W_{UL}$" '] ++ (0,-0.8);
\draw[Fv=red]    (C) ++ (\ubangle:-1.2) coordinate (Fsb) to["$W_{SB}$" ', sloped] (C);

\draw[axis]      (Fsb) ++ (-1,0) -- (Fsb -| C) coordinate (Fsbc);
\pic [my angle, "$31$"]     {angle = Fsbc--Fsb--C};

\draw[Fv=green]  (Dm) to["$F_{M}$" ', sloped]  ++ (195:5) coordinate (Fm);
\pic [my angle, "$\theta$"]     {angle = Dam--Dm--Fm};
\end{tikzpicture}

\end{document}

enter image description here

6
  • Thank you so much!
    – EngK
    May 22, 2022 at 18:47
  • @EngK, if answer show a way, how to draw your image (what about is your question) and and almost complete reproduce desired image, you may consider to accept it (by clicking on check mark at top left side of answer) :-)
    – Zarko
    May 22, 2022 at 19:37
  • Thanks again! If I may ask a follow on question, line 50, etc with the "|-" and "-|", I see that takes the diagonal line off where FN starts and moves it to be a horizontal line at the next vertex. Will you explain what tikz is doing there and the other lines that use it? The manual states "the position (or time)... is exactly the corner point". So in this case, I understand it's being sent to the vertex. But will you explain lines 49-53 please?
    – EngK
    May 23, 2022 at 21:28
  • @EngK, symbol |- or -| designate orthogonal coordinates. See description 13.3.1 Intersections of Perpendicular Lines in TikZ and ŠGF manula, page 143. It denote a coordinate at intersection of vertical line through first coordinate and horizontal line through second coordinate and horizontal line through first coordinate and vertical line through second one.
    – Zarko
    May 23, 2022 at 21:57
  • Thank you again, that was very helpful! If I may ask another question, say I want to put a vertical line straight down from coordinate (D) to ("x",0). I tried: \draw[red, line width = 0.5pt] (D) -- +(0,-13cm) ; However, I have to guess how far "to the ground" to terminate the line. Is there a way to tell tikz to figure out how far down?
    – EngK
    May 25, 2022 at 21:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .