Debian Codegraph @

texmf-dist/tex/latex/tkz-euclide/tkz-tools-eu-angles.tex

raw
1 % tkz-tools-angles.tex
2 % Copyright 2011-2026 Alain Matthes
3 % SPDX-License-Identifier: LPPL-1.3c
4 % Maintainer: Alain Matthes
5
6 \typeout{2026/01/25 5.13c tkz-tools-eu-angles.tex}
7 \makeatletter
8 %<--------------------------------------------------------------------------–>
9 %<--------------------------------------------------------------------------–>
10 % thanks karu : http://tex.stackexchange.com/questions/151667/tkzgetangle-strange-behavior/196224#196224
11 % \tkzGetAngle strange behavior
12 % defines \tkz@FirstAngle and \tkz@SecondAngle sens trigo
13 %<--------------------------------------------------------------------------–>
14 \def\tkzNormalizeAngle(#1,#2){%
15 \begingroup
16 \pgfmathparse{#1}\xdef\tkz@FirstAngle{\pgfmathresult}%
17 \pgfmathparse{#2}\xdef\tkz@SecondAngle{\pgfmathresult}%
18 \pgfmathgreaterthan{\tkz@FirstAngle}{0}
19 \ifdim\pgfmathresult pt=1 pt\relax%
20 \pgfmathgreaterthan{\tkz@FirstAngle}{\tkz@SecondAngle}
21 \ifdim\pgfmathresult pt=1 pt\relax%
22 \pgfmathsubtract{\tkz@FirstAngle}{360}
23 \xdef\tkz@FirstAngle{\pgfmathresult}%
24 \fi
25 \else
26 \pgfmathgreaterthan{\tkz@FirstAngle}{\tkz@SecondAngle}
27 \ifdim\pgfmathresult pt=1 pt\relax%
28 \pgfmathadd{\tkz@SecondAngle}{360}
29 \xdef\tkz@SecondAngle{\pgfmathresult}%
30 \fi
31 \fi
32 \endgroup
33 }
34 %<--------------------------------------------------------------------------–>
35 % Angle
36 % Recherche l'angle formé par #1 et #2 par rapport à l'horizontale
37 %<--------------------------------------------------------------------------–>
38 \def\tkzFindSlopeAngle(#1,#2){%
39 \begingroup
40 \pgfmathanglebetweenpoints{\pgfpointanchor{#1}{center}}{%
41 \pgfpointanchor{#2}{center}}
42 \global\let\tkzAngleResult\pgfmathresult
43 \endgroup
44 }
45 %<--------------------------------------------------------------------------–>
46 % Angle avec trois nodes
47 %<--------------------------------------------------------------------------–>
48 \def\tkzFindAngle(#1,#2,#3){% new code 2016
49 \begingroup
50 \tkzFindSlopeAngle(#2,#1)\tkzGetAngle{tkz@FirstAngle}
51 \tkzFindSlopeAngle(#2,#3)\tkzGetAngle{tkz@SecondAngle}
52 \tkzNormalizeAngle(\tkz@FirstAngle,\tkz@SecondAngle)
53 \edef\tkz@Angle{\fpeval{\tkz@SecondAngle-\tkz@FirstAngle}}
54 \global\let\tkzAngleResult\tkz@Angle
55 \endgroup
56 }
57
58 %<--------------------------------------------------------------------------–>
59 % Find angle
60 %<--------------------------------------------------------------------------–>
61 \def\tkzGetAngle#1{%
62 \global\expandafter\edef\csname #1\endcsname{\tkzAngleResult}
63 }
64 \def\tkzDet(#1,#2,#3){%
65 \tkzFindSlopeAngle(#2,#1)\tkzGetAngle{tkz@FirstAngle}
66 \tkzFindSlopeAngle(#2,#3)\tkzGetAngle{tkz@SecondAngle}
67 \tkzNormalizeAngle(\tkz@FirstAngle,\tkz@SecondAngle)
68 }
69 \makeatother
70 \endinput