1

I am unable to correctly place the alpha angle as well as the rest of this diagram.

diag

My minimal working example (MWE):

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[scale=1]
\fill[white] (-1,-5) rectangle (10,5);
\draw[thin] (0,0) grid (17,5);
\draw[line width=2pt] (0,4)--(15,4);
\draw[decorate,decoration={border,amplitude=0.6cm}] (0,4)--(15,4);
\path 
(3,6.5) node{A} 
(8,4.2) node{B} 
(3,4.2) node{C}
(4,5) node{$\theta$}
(4,4)node{$\vec{F}$};
\begin{scope}[rotate around={-30:(2.69,0)}]
\draw[line width=2pt](-1,5)--(5,6);
\shade[ball color=blue!100!green!150,opacity=5](2,6.02)circle (0.5);
\shade[ball color=blue!100!green!150,opacity=5](8,8.29)circle (0.5);
\end{scope}
\draw[blue] (6.5421,4.449225) arc(91:180:0.4515) node[midway,left]{$\alpha$};
\draw (11.49,4.5)--(15,4.5);

\drawline width=2pt,rotate around={30:(5,-1)}--(17,0.8); \end{tikzpicture} \end{document}


I use \documentclass[12pt]{article}

MS-SPO
  • 11,519
Fractal
  • 378
  • 5
    Please try the following: a) copy your posted code into a new file, b) compile it, c) add the missing parts to your question (this will also give us a clue which opportunities you may have missed); to be perfect, please include a screenshot of your current result. Thank you – MS-SPO Aug 29 '23 at 15:47
  • You can see the complilation here https://www.overleaf.com/read/cktnvkdrgcxc – Fractal Aug 29 '23 at 15:56
  • 3
    Please don't be lazy. Please extend the code you posted here as I described. Nobody will start debugging your code. Please learn distilling your question to present it here. Thank you – MS-SPO Aug 29 '23 at 16:41
  • 1
    @Fractal I have just edited your post. Please read carefully this link to know what does a "MWE" mean https://tex.meta.stackexchange.com/questions/228/ive-just-been-asked-to-write-a-minimal-working-example-mwe-what-is-that PS: Your code, both TeX and TikZ, is full of mess. In generally, people don't like bad code (Are you?). So please clean your code to get better change to be helped – Black Mild Aug 29 '23 at 17:41

2 Answers2

5

Something to help the OP in the framing of a simple angle

All we need is to select three coordinates for enclosing the angle -- in this case the coordinates are B, C, D -- in your code you can modify the selection of coordinates as desired

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{calc} 
\usetikzlibrary{angles,intersections,quotes}
%\usepackage{tkz-euclide}

\begin{document} \begin{tikzpicture} \draw [blue!70!black, thick] (0,0)coordinatelabel=-90:A -- (1,0)coordinatelabel=-90:B -- (10,0) coordinatelabel=-90:C;

    \draw[blue!70!black, thick]
    (B)                                                             --
        +(20:9cm)coordinate[label=90:D](D);

    \pic[ draw,
            <->,
            >=stealth,
            red!60!black, 
            "$\alpha$"{fill=red!20},
            inner sep=1pt, 
            circle, 
            angle eccentricity=1.1, 
            angle radius = 20mm] 
                        {angle = C--B--D}; 

        \end{tikzpicture}
        \end{document}

Output

enter image description here

Note that changing the sequence of coordinates will effect the angle --initially sequence was CBD now changed to DBC

\begin{tikzpicture}
    \draw [blue!70!black, thick]
    (0,0)coordinate[label=-90:A](A)             -- 
        (1,0)coordinate[label=-90:B](B)         -- 
            (10,0) coordinate[label=-90:C](C);
\draw[blue!70!black, thick]
(B)                                                             --
    +(20:9cm)coordinate[label=90:D](D);

\pic[ draw,
        <->,
        >=stealth,
        red!60!black, 
        "$\alpha$"{fill=red!20},
        inner sep=1pt, 
        circle, 
        angle eccentricity=1.1, 
        angle radius = 20mm] 
                    {angle = D--B--C}; 

    \end{tikzpicture}

Output

enter image description here

Also experimenting with the code will give more insight into placement of the \alpha angle -- for example modifying the eccentricity and angle radius in the above code

angle eccentricity=-1.1, 
                angle radius = 13mm
                            {angle = D--B--C};

will result in

enter image description here

Hope this will help in framing a clear angle

js bibra
  • 21,280
4

This reminds me of Tilted things in LaTeX but this diagram is less messy.

But the main takeaway is the same: Don't do trigonometry that TikZ can easily do for you!

Instead of a pic we can place a regular circular node along a path, even an inclined one, and TikZ makes sure it's tangent/parallel. (Since the ball doesn't have its own drawn border we can use the original path's \pgflinewidth to adjust its position ever so slightly so that it actually only touches the line. For this we also set outer sep to zero or auto, this also makes sure that the F vector lines start exactly at the ball.)

Giving important coordinates names we can then use the angle library of the angles library to draw the α and θ angles without having to do any calculations. The pic does those for you.

Code

\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{angles, arrows.meta, decorations.pathreplacing, quotes}
\tikzset{
  ball above the line/.style={
    sloped, allow upside down, above=.5\pgflinewidth, outer sep=+0pt,
    minimum size=1cm, shape=circle, ball color=blue!50},
  border/.style={
    decoration={name=border, amplitude=.6cm, #1},
    postaction={draw, thin, decorate}}}
\begin{document}
\begin{tikzpicture}[>=Latex, angle radius=1cm, angle eccentricity=1.25]
\draw[line width=2pt, border=reverse path]
  (3, 4) coordinate (left)
  -- coordinate["$B$"] (B)
     node[ball above the line, near end] (right ball) {}
  (15,4) coordinate (right);
\draw[thick]
  (3, 6.5) coordinate["$A$"] (A)
  -- node[ball above the line, near start] (left ball) {}
  (B);

\path[at end] (right ball.east) coordinate (rb) edge[->, "$\vec F$"] coordinate (rb-tr) +(30:2) edge[dotted] coordinate (rb-r) +( 0:2);

\pic["$\alpha$", draw] {angle=A--B--left}; \pic["$\theta$", draw] {angle=rb-r--rb--rb-tr}; \end{tikzpicture} \end{document}

Output

enter image description here

Qrrbrbirlbel
  • 119,821