7

I'm aware of the pgf macros:

\pgfmathanglebetweenpoints

and

\pgfmathanglebetweenlines

What I'd like to know is whether there are any macros in tkz-euclide that more easily accomplish the same thing.

For example, if I have two coordinates A and B, to measure the angle of the line passing through these two points, I can write

\pgfmathanglebetweenpoints{\pgfpointanchor{A}{center}}{\pgfpointanchor{B}{center}}
\edef\aeABangle{\pgfmathresult}

It would be convenient if there were a macro in tkz-euclide that could do this in a manner like

\tkzAngleAlong(A,B)

and then have some mechanism to retrieve the value of the angle.

I barely have a reading knowledge of French. It's passable enough that I can usually figure out what's in the manual to tkz-euclide, but it's not sufficient for me to guess key words to search on. So, I apologize if this is already well documented.

I know I could write my own macro to do this. I'd just like to not have to reinvent the wheel (even though it's a relatively simple wheel to recreate).

A.Ellett
  • 50,533

1 Answers1

7

Basically you have:

  1. \tkzFindAngle(c,b,a)
    The angle in the center is the one being found. Or in this case, the vertex b.
  2. \tkzGetAngle{angleCBA}
    Gives the name to the angle.
  3. \FPround\angleCBA\angleCBA{0}
    Rounds the angle to integers. The 0 indicates numbers after the decimal separator. I set one angle to have 10 of them as a demonstration.
  4. \tkzMarkAngle[size=.5](c,b,a)
    Marks the angle with the arc. You can customize this using draw, fill and even opacity.
  5. \tkzLabelAngle[pos=-.82](c,b,a){\tiny $\angleCBA^\circ$}
    Labels the angle. Pos indicates the position of the label, while the rest is similar to the syntax of a node. (c,b,a) indicates what angle/where the label should appear; and $\angleCBA$ prints the angle.

Output

figure 1

Code

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

\tikzset{ myangle/.style={fill=green!20!white, draw=green!50!black,size=.3,opacity=.3} }

\begin{document} \begin{tikzpicture}

\coordinate (a) at (0,0); \coordinate (b) at (5,3); \coordinate (c) at (3,6);

\draw (a) coordinate[label=left:A] -- (b) coordinate[label=right:B] -- (c) coordinate[label=above:C] -- cycle;

\tkzFindAngle(c,b,a)\tkzGetAngle{angleCBA}\FPround\angleCBA\angleCBA{0} \tkzFindAngle(a,c,b)\tkzGetAngle{angleACB}\FPround\angleACB\angleACB{10} \tkzFindAngle(b,a,c)\tkzGetAngle{angleBAC}\FPround\angleBAC\angleBAC{0}

\tkzMarkAnglesize=.5 \tkzLabelAnglepos=-.82{\tiny $\angleCBA^\circ$}

\tkzMarkAnglesize=.5 \tkzLabelAnglepos=0.6{\tiny $\angleACB^\circ$}

\tkzMarkAnglesize=.5 \tkzLabelAnglepos=.7{\tiny $\angleBAC^\circ$}

\end{tikzpicture} \end{document}

PatrickT
  • 2,923
Alenanno
  • 37,338
  • Very nice work. – A.Ellett May 23 '15 at 19:51
  • @A.Ellett I noticed a problem though (trying to fix it), but the angle B shouldn't be -273. It never happened to me. I'm looking into it. – Alenanno May 23 '15 at 20:02
  • I noticed that too, but I wasn't worried about that part. – A.Ellett May 23 '15 at 20:19
  • Hi Alenanno, is it possible to use \FPRound with measuring arcs of circles? See e.g. this question: https://tex.stackexchange.com/questions/542375/perfect-labels-for-minor-major-arcs-of-circle-using-tkz-euclide – EthanAlvaree May 19 '21 at 10:52
  • Great answer! I tried with\tikzset{myangle/.style={size=.5}} and passing \tkzMarkAngle[myangle](b,a,c), but that's giving an error. Tried adding units like size=.5cm, but that didn't work either. Should I not expect it to work? should I ask a new question? thanks! – PatrickT Feb 27 '24 at 05:27
  • Here: https://tex.stackexchange.com/questions/710071/tkz-euclide-set-style-of-angle-marks-globally – PatrickT Mar 02 '24 at 10:18