0

How can I draw friction lines under the box $M$ in the following TikZ draw...?

\begin{figure}[h]
            \centering
            \begin{tikzpicture} [font = \small]
            % triangle:
            \draw [draw = orange, fill = orange!15] (0,0) coordinate (O) -- (\ang:6)
            coordinate [pos=.45] (M) |- coordinate (B) (O);

            % angles:
            \draw [draw = orange] (O) ++(.8,0) arc (0:\ang:0.8) 
            node [pos=.4, left] {$\theta$};
            \draw [draw = orange] (B) rectangle ++(-0.3,0.3);

            \begin{scope} [-latex,rotate=\ang]
                % Object (rectangle)
                \draw [fill = purple!30,
                draw = purple!50] (M) rectangle node [] {$M$} ++ (1,.6) ;
            \end{scope}

        \end{tikzpicture}
    \end{figure}

enter image description here

hyriusen
  • 167

1 Answers1

3

I am not fully sure whether this is about what you want, but a solution in reference to my other answer could be:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns}

\begin{document} \begin{tikzpicture}[font=\small]

\pgfmathsetmacro{\ang}{30}

% triangle:
\begin{scope}
    \path[save path=\triangle, clip] (0,0) coordinate (O) 
        -- (\ang:6) coordinate[pos=.45] (M) |- coordinate (B) cycle;
    \fill[orange!15] [use path=\triangle];
    \fill[pattern=vertical lines, pattern color=orange!50] (O) -- (\ang:6) -- ++(0,-.25) -- (0,-.25) -- cycle;
\end{scope}
\draw[orange] [use path=\triangle];

% angles:
\draw[orange] (O) ++(.8,0) arc[start angle=0, end angle={\ang}, radius=0.8]
    node[pos=.4, left, black] {$\theta$};
\draw[orange] (B) rectangle ++(-0.3,0.3);

\begin{scope}[rotate=\ang]
    % Object (rectangle)
    \draw[purple!50, fill=purple!30] (M) rectangle node[black] {$M$} ++(1,.6);
\end{scope}

\end{tikzpicture} \end{document}

enter image description here

Note that I used the same path three times: for clipping the shape with the pattern, to fill the triangle and to finally draw an outline. This is maybe not the best solution.

Another solution could be to calculate the exact coordinates of the shape with the pattern like so:

\draw[orange, fill=orange!15] (0,0) coordinate (O) 
    -- (\ang:6) coordinate[pos=.45] (M) |- coordinate (B) cycle;
\fill[pattern=vertical lines, pattern color=orange!50] (O) 
    -- (\ang:6) -- ++(0,-.25) -- ({.25/tan(\ang)},0) -- cycle;

No clipping and re-using of paths would be needed then.


As @MS-SPO noted, you might want to add the friction lines to the rectangular object as well:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns}

\begin{document} \begin{tikzpicture}[font=\small]

\pgfmathsetmacro{\ang}{30}

% triangle:
\draw[orange, fill=orange!15] (0,0) coordinate (O) 
    -- (\ang:6) coordinate[pos=.45] (M) |- coordinate (B) cycle;
\fill[pattern=vertical lines, pattern color=orange!50] (O) 
    -- (\ang:6) -- ++(0,-.25) -- ({.25/tan(\ang)},0) -- cycle;

% angles:
\draw[orange] (O) ++(.8,0) arc[start angle=0, end angle={\ang}, radius=0.8]
    node[pos=.4, left, black] {$\theta$};
\draw[orange] (B) rectangle ++(-0.3,0.3);

\begin{scope}[rotate=\ang]
    % Object (rectangle)
    \draw[purple!50, fill=purple!30] (M) rectangle node[black] {$M$} ++(1,.6);
    \fill[pattern=vertical lines, pattern color=purple!45] 
        (M) rectangle ++(1,.25);
\end{scope}

\end{tikzpicture} \end{document}

enter image description here

  • Very nice :) For physical correctness the OP should add a pattern to the box M bottom as well, as it probably will also be a physical object from the real world ;-) – MS-SPO Feb 17 '24 at 18:19
  • @MS-SPO Where would you place the lilnes then? Only at the side where the friction happens, I guess? – Jasper Habicht Feb 17 '24 at 18:20
  • The contact zone between both objects is relevant, i.e. the orange lines you drew, plus where M is in touch with the orange surface. // For visualization just think of turning the problem upside down, fixating M and letting the orang surface slide down. Same generic problem. – MS-SPO Feb 17 '24 at 18:21
  • 1
    @MS-SPO Nice! I added this to the answer. Thanks for the notice! – Jasper Habicht Feb 17 '24 at 18:24