Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
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. –  Qrrbrbirlbel Aug 24 '13 at 18:51

1 Answer 1

up vote 4 down vote accepted

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}

enter image description here

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.