| 1 |
% tkz-obj-eu-sectors.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-obj-eu-sectors.tex} |
| 7 |
\makeatletter |
| 8 |
%<----------------------- Sectors ------------------------------–> |
| 9 |
\gdef\tkz@nums{0} |
| 10 |
\pgfkeys{/drawsector/.cd, |
| 11 |
towards/.code = {\def\tkz@nums{0}}, |
| 12 |
rotate/.code = {\def\tkz@nums{1}}, |
| 13 |
R/.code = {\def\tkz@nums{2}}, |
| 14 |
R with nodes/.code = {\def\tkz@nums{3}}, |
| 15 |
towards, |
| 16 |
/drawsector/.search also = {/tikz}, |
| 17 |
} |
| 18 |
|
| 19 |
\def\tkzDrawSector{\pgfutil@ifnextchar[{\tkz@DrawSector}{\tkz@DrawSector[]}} |
| 20 |
\def\tkz@DrawSector[#1](#2,#3)(#4){% |
| 21 |
\begingroup |
| 22 |
\pgfqkeys{/drawsector}{#1} |
| 23 |
\ifcase\tkz@nums% |
| 24 |
\tkzDrawSectorN[#1](#2,#3)(#4) |
| 25 |
\or% 1 |
| 26 |
\tkzDrawSectorRotate[#1](#2,#3)(#4) |
| 27 |
\or% 2 |
| 28 |
\tkzDrawSectorRAngles[#1](#2,#3)(#4) |
| 29 |
\or% 3 |
| 30 |
\tkzDrawSectorR[#1](#2,#3)(#4) |
| 31 |
\fi |
| 32 |
\endgroup |
| 33 |
} |
| 34 |
\def\tkzDrawSectorRAngles{\pgfutil@ifnextchar[{\tkz@DrawSectorRAngles}{% |
| 35 |
\tkz@DrawSectorRAngles[]}} |
| 36 |
\def\tkz@DrawSectorRAngles[#1](#2,#3)(#4,#5){% |
| 37 |
\begingroup |
| 38 |
\pgfmathparse{#4}\edef\tkz@FirstAngle{\pgfmathresult}% |
| 39 |
\pgfmathparse{#5}\edef\tkz@SecondAngle{\pgfmathresult}% |
| 40 |
\pgfmathgreaterthan{\tkz@FirstAngle}{0} |
| 41 |
\ifdim\pgfmathresult pt=1 pt\relax% |
| 42 |
\pgfmathgreaterthan{\tkz@FirstAngle}{\tkz@SecondAngle} |
| 43 |
\ifdim\pgfmathresult pt=1 pt\relax% |
| 44 |
\pgfmathsubtract{\tkz@FirstAngle}{360} |
| 45 |
\edef\tkz@FirstAngle{\pgfmathresult}% |
| 46 |
\fi |
| 47 |
\else |
| 48 |
\pgfmathgreaterthan{\tkz@FirstAngle}{\tkz@SecondAngle} |
| 49 |
\ifdim\pgfmathresult pt=1 pt\relax% |
| 50 |
\pgfmathadd{\tkz@SecondAngle}{360} |
| 51 |
\edef\tkz@SecondAngle{\pgfmathresult}% |
| 52 |
\fi |
| 53 |
\fi |
| 54 |
\draw[shift = {(#2)},/drawsector/.cd,#1]% |
| 55 |
(#2) --(\tkz@FirstAngle:#3) arc (\tkz@FirstAngle:\tkz@SecondAngle:#3)--cycle; |
| 56 |
\endgroup |
| 57 |
} % revoir il y a plus simple que ce shift !!! |
| 58 |
%<--------------------------------------------------------------------------–> |
| 59 |
% \tkzDrawSectorN(O,A)(B) |
| 60 |
%<--------------------------------------------------------------------------–> |
| 61 |
\def\tkzDrawSectorN{\pgfutil@ifnextchar[{\tkz@DrawSectorN}{% |
| 62 |
\tkz@DrawSectorN[]}} |
| 63 |
\def\tkz@DrawSectorN[#1](#2,#3)(#4){% |
| 64 |
\begingroup |
| 65 |
\tkz@@CalcLengthcm(#2,#3){tkz@radius} |
| 66 |
\tkzFindSlopeAngle(#2,#3)\tkzGetAngle{tkz@FirstAngle} |
| 67 |
\tkzFindSlopeAngle(#2,#4)\tkzGetAngle{tkz@SecondAngle} |
| 68 |
\tkz@DrawSectorRAngles[#1](#2,\tkz@radius)(\tkz@FirstAngle,% |
| 69 |
\tkz@SecondAngle) |
| 70 |
\endgroup |
| 71 |
} |
| 72 |
%<--------------------------------------------------------------------------–> |
| 73 |
% \tkzDrawSectorRotate(O,A)(angle de rotation) ??? pb avec angle negatif |
| 74 |
%<--------------------------------------------------------------------------–> |
| 75 |
\def\tkzDrawSectorRotate{\pgfutil@ifnextchar[{\tkz@DrawSectorRotate}{% |
| 76 |
\tkz@DrawSectorRotate[]}} |
| 77 |
\def\tkz@DrawSectorRotate[#1](#2,#3)(#4){% |
| 78 |
\begingroup |
| 79 |
\tkz@@CalcLengthcm(#2,#3){tkz@radius} |
| 80 |
\tkzFindSlopeAngle(#2,#3)\tkzGetAngle{tkz@FirstA} |
| 81 |
\pgfmathadd{\tkz@FirstA}{#4} |
| 82 |
\edef\tkz@SecondA{\pgfmathresult} |
| 83 |
\pgfmathgreaterthan{#4}{0} |
| 84 |
\ifdim\pgfmathresult pt=1 pt\relax% |
| 85 |
\tkz@DrawSectorRAngles[#1](#2,\tkz@radius)(\tkz@FirstA,\tkz@SecondA) |
| 86 |
\else |
| 87 |
\tkz@DrawSectorRAngles[#1](#2,\tkz@radius)(\tkz@SecondA,\tkz@FirstA) |
| 88 |
\fi |
| 89 |
\endgroup |
| 90 |
} |
| 91 |
% %<--------------------------------------------------------------------------–> |
| 92 |
|
| 93 |
%<--------------------------------------------------------------------------–> |
| 94 |
% \tkzDrawSectorR(O, rad)(A,B) |
| 95 |
%<--------------------------------------------------------------------------–> |
| 96 |
\def\tkzDrawSectorR{\pgfutil@ifnextchar[{\tkz@DrawSectorR}{% |
| 97 |
\tkz@DrawSectorR[]}} |
| 98 |
\def\tkz@DrawSectorR[#1](#2,#3)(#4,#5){% |
| 99 |
\begingroup |
| 100 |
\tkzFindSlopeAngle(#2,#4)\tkzGetAngle{tkz@FirstAngle} |
| 101 |
\tkzFindSlopeAngle(#2,#5)\tkzGetAngle{tkz@SecondAngle} |
| 102 |
\tkz@DrawSectorRAngles[#1](#2,#3)(\tkz@FirstAngle,\tkz@SecondAngle) |
| 103 |
\endgroup |
| 104 |
} |
| 105 |
%<--------------------------------------------------------------------------–> |
| 106 |
% Fill |
| 107 |
%<--------------------------------------------------------------------------–> |
| 108 |
\gdef\tkz@nums{0} |
| 109 |
\pgfkeys{/@fillsector/.cd, |
| 110 |
towards/.code = {\def\tkz@nums{0}}, |
| 111 |
rotate/.code = {\def\tkz@nums{1}}, |
| 112 |
R/.code = {\def\tkz@nums{2}}, |
| 113 |
R with nodes/.code = {\def\tkz@nums{3}}, |
| 114 |
towards, |
| 115 |
/@fillsector/.search also={/tikz}, |
| 116 |
} |
| 117 |
|
| 118 |
\def\tkzFillSector{\pgfutil@ifnextchar[{\tkz@FillSector}{\tkz@FillSector[]}} |
| 119 |
\def\tkz@FillSector[#1](#2,#3)(#4){% |
| 120 |
\begingroup |
| 121 |
\pgfqkeys{/@fillsector}{#1} |
| 122 |
\ifcase\tkz@nums% |
| 123 |
\tkzFillSectorN[#1](#2,#3)(#4) |
| 124 |
\or% 1 |
| 125 |
\tkzFillSectorRotate[#1](#2,#3)(#4) |
| 126 |
\or% 2 |
| 127 |
\tkzFillSectorRAngles[#1](#2,#3)(#4) |
| 128 |
\or% 3 |
| 129 |
\tkzFillSectorR[#1](#2,#3)(#4) |
| 130 |
\fi |
| 131 |
\endgroup |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
\def\tkzFillSectorRAngles{\pgfutil@ifnextchar[{\tkz@FillSectorRAngles}{% |
| 136 |
\tkz@FillSectorRAngles[]}} |
| 137 |
\def\tkz@FillSectorRAngles[#1](#2,#3)(#4,#5){% |
| 138 |
\begingroup |
| 139 |
\pgfmathparse{#4}\edef\tkz@FirstAngle{\pgfmathresult}% |
| 140 |
\pgfmathparse{#5}\edef\tkz@SecondAngle{\pgfmathresult}% |
| 141 |
\pgfmathgreaterthan{\tkz@FirstAngle}{0} |
| 142 |
\ifdim\pgfmathresult pt=1 pt\relax% |
| 143 |
\pgfmathgreaterthan{\tkz@FirstAngle}{\tkz@SecondAngle} |
| 144 |
\ifdim\pgfmathresult pt=1 pt\relax% |
| 145 |
\pgfmathsubtract{\tkz@FirstAngle}{360} |
| 146 |
\edef\tkz@FirstAngle{\pgfmathresult}% |
| 147 |
\fi |
| 148 |
\else |
| 149 |
\pgfmathgreaterthan{\tkz@FirstAngle}{\tkz@SecondAngle} |
| 150 |
\ifdim\pgfmathresult pt=1 pt\relax% |
| 151 |
\pgfmathadd{\tkz@SecondAngle}{360} |
| 152 |
\edef\tkz@SecondAngle{\pgfmathresult}% |
| 153 |
\fi\fi |
| 154 |
\pgfmathsubtract{\tkz@FirstAngle}{0} |
| 155 |
\edef\tkz@FirstAngle{\pgfmathresult}% |
| 156 |
\pgfmathadd{\tkz@SecondAngle}{0} |
| 157 |
\edef\tkz@SecondAngle{\pgfmathresult} |
| 158 |
\path[shift = {(#2)},/@fillsector/.cd,fill=\tkz@fillcolor,#1] (#2) -- % |
| 159 |
(\tkz@FirstAngle:#3) arc (\tkz@FirstAngle:\tkz@SecondAngle:#3)--cycle; |
| 160 |
\endgroup |
| 161 |
} |
| 162 |
%<--------------------------------------------------------------------------–> |
| 163 |
% \tkzFillSectorN(O,A)(B) |
| 164 |
%<--------------------------------------------------------------------------–> |
| 165 |
\def\tkzFillSectorN{\pgfutil@ifnextchar[{\tkz@FillSectorN}{\tkz@FillSectorN[]}} |
| 166 |
\def\tkz@FillSectorN[#1](#2,#3)(#4){% |
| 167 |
\begingroup |
| 168 |
\tkz@@CalcLength(#2,#3){tkz@radius} |
| 169 |
\tkzFindSlopeAngle(#2,#3)\tkzGetAngle{tkz@FirstAngle} |
| 170 |
\tkzFindSlopeAngle(#2,#4)\tkzGetAngle{tkz@SecondAngle} |
| 171 |
\tkz@FillSectorRAngles[#1](#2,\tkz@radius pt)(\tkz@FirstAngle,% |
| 172 |
\tkz@SecondAngle) |
| 173 |
\endgroup |
| 174 |
} |
| 175 |
%<--------------------------------------------------------------------------–> |
| 176 |
% \tkzFillSectorRotate(O,A)(angle de rotation) ??? pb avec angle negatif |
| 177 |
%<--------------------------------------------------------------------------–> |
| 178 |
\def\tkzFillSectorRotate{\pgfutil@ifnextchar[{\tkz@FillSectorRotate}{% |
| 179 |
\tkz@FillSectorRotate[]}} |
| 180 |
\def\tkz@FillSectorRotate[#1](#2,#3)(#4){% |
| 181 |
\begingroup |
| 182 |
\tkz@@CalcLength(#2,#3){tkz@radius} |
| 183 |
\tkzFindSlopeAngle(#2,#3)\tkzGetAngle{tkz@FirstA} |
| 184 |
\pgfmathadd{\tkz@FirstA}{#4} |
| 185 |
\edef\tkz@SecondA{\pgfmathresult} |
| 186 |
\pgfmathgreaterthan{#4}{0} |
| 187 |
\ifdim\pgfmathresult pt=1 pt\relax% |
| 188 |
\tkz@FillSectorRAngles[#1](#2,\tkz@radius pt)(\tkz@FirstA,\tkz@SecondA) |
| 189 |
\else |
| 190 |
\tkz@FillSectorRAngles[#1](#2,\tkz@radius pt)(\tkz@SecondA,\tkz@FirstA) |
| 191 |
\fi |
| 192 |
\endgroup |
| 193 |
} |
| 194 |
%<--------------------------------------------------------------------------–> |
| 195 |
% \tkzFillSectorAngles(O,A)(ang1,ang2) |
| 196 |
%<--------------------------------------------------------------------------–> |
| 197 |
\def\tkzFillSectorAngles{\pgfutil@ifnextchar[{\tkz@FillSectorAngles}{% |
| 198 |
\tkz@FillSectorAngles[]}} |
| 199 |
\def\tkz@FillSectorAngles[#1](#2,#3)(#4,#5){% |
| 200 |
\begingroup |
| 201 |
\tkz@@CalcLength(#2,#3){tkz@radius} |
| 202 |
\tkz@FillSectorRAngles[#1](#2,\tkz@radius pt)(#4,#5) |
| 203 |
\endgroup |
| 204 |
} |
| 205 |
%<--------------------------------------------------------------------------–> |
| 206 |
% \tkzFillSectorR(O, rad)(A,B) |
| 207 |
%<--------------------------------------------------------------------------–> |
| 208 |
\def\tkzFillSectorR{\pgfutil@ifnextchar[{\tkz@FillSectorR}{% |
| 209 |
\tkz@FillSectorR[]}} |
| 210 |
\def\tkz@FillSectorR[#1](#2,#3)(#4,#5){% |
| 211 |
\begingroup |
| 212 |
\tkzFindSlopeAngle(#2,#4)\tkzGetAngle{tkz@FirstAngle} |
| 213 |
\tkzFindSlopeAngle(#2,#5)\tkzGetAngle{tkz@SecondAngle} |
| 214 |
\tkz@FillSectorRAngles[#1](#2,#3)(\tkz@FirstAngle,\tkz@SecondAngle) |
| 215 |
\endgroup |
| 216 |
} |
| 217 |
%<--------------------------- Clip Sector ----------------------------------–> |
| 218 |
% |
| 219 |
%<--------------------------------------------------------------------------–> |
| 220 |
\def\tkz@ClipSectorRAngles(#1,#2)(#3,#4){% |
| 221 |
\pgfmathparse{#3}\edef\tkz@FirstAngle{\pgfmathresult}% |
| 222 |
\pgfmathparse{#4}\edef\tkz@SecondAngle{\pgfmathresult}% |
| 223 |
\pgfmathgreaterthan{\tkz@FirstAngle}{0} |
| 224 |
\ifdim\pgfmathresult pt=1 pt\relax% |
| 225 |
\pgfmathgreaterthan{\tkz@FirstAngle}{\tkz@SecondAngle} |
| 226 |
\ifdim\pgfmathresult pt=1 pt\relax% |
| 227 |
\pgfmathsubtract{\tkz@FirstAngle}{360} |
| 228 |
\edef\tkz@FirstAngle{\pgfmathresult}% |
| 229 |
\fi |
| 230 |
\else |
| 231 |
\pgfmathgreaterthan{\tkz@FirstAngle}{\tkz@SecondAngle} |
| 232 |
\ifdim\pgfmathresult pt=1 pt\relax% |
| 233 |
\pgfmathadd{\tkz@SecondAngle}{360} |
| 234 |
\edef\tkz@SecondAngle{\pgfmathresult}% |
| 235 |
\fi |
| 236 |
\fi |
| 237 |
\clip[shift = {(#1)}] (#1) --(\tkz@FirstAngle:#2)% |
| 238 |
arc(\tkz@FirstAngle:\tkz@SecondAngle:#2) -- cycle; |
| 239 |
} |
| 240 |
%<--------------------------------------------------------------------------–> |
| 241 |
% |
| 242 |
%<--------------------------------------------------------------------------–> |
| 243 |
\def\tkz@ClipSectorRotate(#1,#2)(#3){% |
| 244 |
\tkz@@CalcLength(#1,#2){tkz@radius} |
| 245 |
\tkzFindSlopeAngle(#1,#2)\tkzGetAngle{tkz@FirstA} |
| 246 |
\pgfmathadd{\tkz@FirstA}{#3} |
| 247 |
\edef\tkz@SecondA{\pgfmathresult} |
| 248 |
\pgfmathgreaterthan{#3}{0} |
| 249 |
\ifdim\pgfmathresult pt=1 pt\relax% |
| 250 |
\tkz@ClipSectorRAngles(#1,\tkz@radius pt)(\tkz@FirstA,\tkz@SecondA) |
| 251 |
\else |
| 252 |
\tkz@ClipSectorRAngles(#1,\tkz@radius pt)(\tkz@SecondA,\tkz@FirstA) |
| 253 |
\fi |
| 254 |
} |
| 255 |
%<--------------------------------------------------------------------------–> |
| 256 |
% |
| 257 |
%<--------------------------------------------------------------------------–> |
| 258 |
\def\tkz@ClipSectorN(#1,#2)(#3){% |
| 259 |
\tkz@@CalcLength(#1,#2){tkz@radius} |
| 260 |
\tkzFindSlopeAngle(#1,#2)\tkzGetAngle{tkz@FirstAngle} |
| 261 |
\tkzFindSlopeAngle(#1,#3)\tkzGetAngle{tkz@SecondAngle} |
| 262 |
\tkz@ClipSectorRAngles(#1,\tkz@radius pt)(\tkz@FirstAngle,\tkz@SecondAngle) |
| 263 |
} |
| 264 |
%<--------------------------------------------------------------------------–> |
| 265 |
%<--------------------------------------------------------------------------–> |
| 266 |
\def\tkz@numcs{0} |
| 267 |
\pgfkeys{/clipsector/.cd, |
| 268 |
towards/.code = {\def\tkz@numcs{0}}, |
| 269 |
rotate/.code = {\def\tkz@numcs{1}}, |
| 270 |
R/.code = {\def\tkz@numcs{2}}, |
| 271 |
} |
| 272 |
%<--------------------------------------------------------------------------–> |
| 273 |
\def\tkzClipSector{\pgfutil@ifnextchar[{\tkz@ClipSector}{% |
| 274 |
\tkz@ClipSector[]}} |
| 275 |
|
| 276 |
\def\tkz@ClipSector[#1](#2,#3)(#4){% |
| 277 |
\pgfkeys{/clipsector/.cd} |
| 278 |
\pgfqkeys{/clipsector}{#1} |
| 279 |
\ifcase\tkz@numcs% |
| 280 |
\tkz@ClipSectorN(#2,#3)(#4) |
| 281 |
\or% 1 |
| 282 |
\tkz@ClipSectorRotate(#2,#3)(#4) |
| 283 |
\or% 2 |
| 284 |
\tkz@ClipSectorRAngles(#2,#3)(#4) |
| 285 |
\fi |
| 286 |
} |
| 287 |
\makeatother |
| 288 |
\endinput |