4

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

enter image description here

\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}
2
  • 1
    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. Commented Aug 24, 2013 at 18:51
  • 1
    No ; with the code of tkz-euclide. Here tkzGetAngle gets a wrong value. You need to use \tkzFindAngle(B,A,C) just before. Commented Aug 11, 2018 at 10:15

1 Answer 1

5

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}
% code from tikz
\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);
% code from tkz-euclide no ;
\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}

enter image description here

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

You must log in to answer this question.

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