# the \tkzGetAngle and \tkzAngleResult, precision

How can you specify the precision of the angle and using the absolute value of the angle in ° ' and "

\documentclass{article}
\usepackage{pgfplots}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{center}
\begin{tikzpicture}
\coordinate (M) at (0,0) ;
\coordinate (A) at (canvas polar cs:angle=80,radius=4cm) ;
\coordinate (B) at (canvas polar cs:angle=-40,radius=4cm) ;
\coordinate (C) at (canvas polar cs:angle=30,radius=4cm);
\coordinate (D) at (canvas polar cs:angle=125,radius=4cm);
\coordinate (E) at (canvas polar cs:angle=200,radius=4cm);
\coordinate (F) at (canvas polar cs:angle=245,radius=4cm);
\draw (M) circle (4cm);
\draw (B) -- (A) -- (C);
\draw (B) -- (D) -- (C);
\draw (B) -- (E) -- (C);
\draw (B) -- (F) -- (C);
\tkzDrawPoints(A,B,C,D,E,F,M);
\tkzLabelPoints[above](A);
\tkzLabelPoints(B,C,M);
\tkzLabelPoints[left](D,E,F);
\tkzMarkAngle[fill= red,size=1.5cm, opacity=.4](B,A,C);
\tkzMarkAngle[fill= red,size=1.5cm, opacity=.4](B,D,C);
\tkzMarkAngle[fill= red,size=1.5cm, opacity=.4](B,E,C);
\tkzMarkAngle[fill= red,size=1.5cm, opacity=.4](B,F,C);
%\tkzLabelAngle[pos = 0.8](B,A,C){$\alpha$};
\tkzLabelAngle[pos = 0.8](B,D,C){$\beta$};
\tkzLabelAngle[pos = 0.8](B,E,C){$\gamma$};
\tkzLabelAngle[pos = 0.8](B,F,C){$\delta$};
\tkzGetAngle{angleBAC};
\tkzLabelAngle[pos = 0.8](B,A,C){\tkzAngleResult};
\end{tikzpicture}
\end{center}
\end{document}

-
The problem here is TeX’s precision (which is bad). You certainly can round the value, either with TeX or PGF math or siunitx. But if you want a precise value (for further calculation or to export it) even if it’s not an integer, you will need to use the fpu library or the fixedpointarithmetic library of PGF/TikZ. The latter uses the fp package. – Qrrbrbirlbel Aug 24 '13 at 18:51

To get the positive angle, you can use \tkzFindAngle(B,A,C). It works for this case at least. Then you use \tkzGetAngle{angleBAC} to save the result in \angleBAC.

To round it off, you can use \FPround\angleBAC\angleBAC{2} (demonstrated in example 20.7 of the manual), but that is not what you're after, I see.

To get the angle on the form DD°MM'SS" I create a macro ddToddmmss that converts an angle from decimal degrees to that form using PGF's math functions, and printing the result. Used with \ddToddmmss{\angleBAC}, on the unrounded angle.

Stripping a lot of unnecessary stuff from your example (you're not even using pgfplots):

\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\makeatletter
\newcommand\ddToddmmss[1]{%
\pgfmathtruncatemacro\deg@tmp{#1}%
\pgfmathsetmacro\min@tmp{(#1-\deg@tmp)*60}%
\pgfmathtruncatemacro\Min@tmp{\min@tmp}
\pgfmathtruncatemacro\sec@tmp{(\min@tmp-floor(\min@tmp))*60}%
\ensuremath{\deg@tmp^\circ \Min@tmp ' \sec@tmp ''}}
\makeatother
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (canvas polar cs:angle=80,radius=4cm) ;
\coordinate (B) at (canvas polar cs:angle=-40,radius=4cm) ;
\coordinate (C) at (canvas polar cs:angle=30,radius=4cm);
\draw (B) -- (A) -- (C);
\tkzDrawPoints(A,B,C);
\tkzLabelPoints[above](A);
\tkzLabelPoints(B,C);
\tkzMarkAngle[fill= red,size=1.5cm, opacity=.4](B,A,C);
\tkzFindAngle(B,A,C)
\tkzGetAngle{angleBAC};
%\FPround\angleBAC\angleBAC{2}
\tkzLabelAngle[pos = 0.8](B,A,C){\ddToddmmss{\angleBAC}};
\end{tikzpicture}
\end{document}


-
Thanks, could you get 34°33'34" as a notation? – Arne Timperman Aug 24 '13 at 19:09
@Arne Sorry, missed that part. Not sure, I'll try. – Torbjørn T. Aug 24 '13 at 19:11
@TorbjørnT. siunitx has the arc notation. – percusse Aug 24 '13 at 19:12
@qrrbrbirlbel sorry I didn't saw your comment – Arne Timperman Aug 24 '13 at 19:12