0

I need to draw arcs to denote angles inside an equilateral triangle. To do this, I am using the arc function in tikz with the help of the calc package. However, if I use an automatic solution which computes the degrees of the difference vectors between the vertexes, I get an undesired result (the black arc in the following example code).

\begin{tikzpicture}[scale=8]
\coordinate (center) at (0, 0);
\coordinate (A) at (-0.5, 0);
\coordinate (B) at (0.5, 0);
\coordinate (C) at (0, {sqrt(3)/2});
\draw (A) -- (B) -- (C) -- cycle;
\coordinate (C1) at ($(C)!0.1!(A)$);
\coordinate (C2) at ($(C)!0.1!(B)$);
\draw
   let \p1 = ($(C1) - (C)$),
   \p2 = ($(C2) - (C)$),
   \n0 = {veclen(\x1,\y1)},            
   \n1 = {atan2(\x1, \y1)},  
   \n2 = {atan2(\x2, \y2)}   
 in (C) arc(\n1:\n2:\n0);
\path
    let     \p1 = ($(C1) - (C)$),
\p2 = ($(C2) - (C)$),
\n0 = {veclen(\x1, \y1)},
\n1 = {atan2(\x1, \y1)},
\n2 = {atan2(\x2, \y2)}
in node at  (C) {$\n1,\, \n2$};
\draw[red] (C1) arc(240:300:0.1);
\end{tikzpicture}

If I display the values of the initial an final angles, they appear in pt which converted are like +60° and -60°. These values are clearly wrong. Vice versa, if I set the correct angles manually, then the arc is fine. Nevertheless, I need to go through the "automatic" solution because I cannot manually compute the initial and final angles for more complex figures. Can anybody tell me how to fix this problem? Also, is there a way to display the initial and final angles in degrees rather than in points? Thank you very much!

3
  • 1
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. In particular, you seem to have certain TikZ libraries missing.
    – JP-Ellis
    Commented Feb 18, 2016 at 22:13
  • 1
    You can't give an angle in pts as far as I know. That gives a length-type dimension. You know there is an angle library for drawing angles?
    – cfr
    Commented Feb 18, 2016 at 22:50
  • Why the huge scale?
    – Alenanno
    Commented Feb 19, 2016 at 0:51

2 Answers 2

1

Perhaps you just want this?

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=8]
  \draw (-0.5,0) coordinate (A) -- (0.5,0) coordinate (B) -- (0,{sqrt(3)/2}) coordinate (C) -- cycle ($(C)!0.1!(A)$) coordinate (C1) ($(C)!0.1!(B)$) coordinate (C2);
  \draw
  let \p1 = ($(C1) - (C)$),
  \p2 = ($(C2) - (C)$),
  \n0 = {veclen(\x1,\y1)},
  \n1 = {atan2(\y1,\x1)},
  \n2 = {atan2(\y2,\x2)}
  in (C1) arc(\n1:\n2:\n0);
\end{tikzpicture}
\end{document}

angle

Note that atan2 takes the y bit as its first argument - not the x - and that the arc should start from (C1) and not (C).

2
  • If the problem is only how designate angle by arc, than far more simpler is to use library angles and write \pic {angle = A--C--B}; and omitted all calculation of trigonometric functions.
    – Zarko
    Commented Feb 19, 2016 at 0:49
  • @Zarko Yes. I mentioned that in comments. But I'm assuming from the question that that won't work in the author's real document because I take it the actual value is wanted back and I'm not sure how to get that from the pic in the angle library.
    – cfr
    Commented Feb 19, 2016 at 1:07
1

Not sure why you decided to apply such a huge scale, instead of just using bigger measurements. Although this means loading an extra package, here's an example with tkz-euclide.

Output

enter image description here

Code

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}
\begin{tikzpicture}
\tkzDefPoint(-4,0){A}
\tkzDefPoint(4,0){B}

\tkzDefTriangle[equilateral](A,B)
\tkzGetPoint{C}

\tkzDrawPolygon(A,B,C)

\tkzMarkAngle[size=1cm](A,C,B)
\end{tikzpicture}
\end{document}

You must log in to answer this question.

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