| 1 |
% tkz-obj-el-points-with.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-points-with.tex} |
| 7 |
\makeatletter |
| 8 |
%<--------------------------------------------------------------------------–> |
| 9 |
% Vectors |
| 10 |
%<--------------------------------------------------------------------------–> |
| 11 |
% Objet : outils mathématiques pour la géométrie euclideienne avec pgf/tikz |
| 12 |
% utilisable de préférence avec un repère orthonormé et le cm comme unité |
| 13 |
% utile pour la compatibilité avec pgf 2 |
| 14 |
%<--------------------------------------------------------------------------–> |
| 15 |
% Duplicate Length à revoir pas de pt pas de global |
| 16 |
% ||v(CN)||= ||v(AB)|| et v(CN) colineaire à v(CD) |
| 17 |
% A-->#1 B-->#2 C-->#3 D-->#4 N-->#5 ????? |
| 18 |
%<--------------------------------------------------------------------------–> |
| 19 |
%<--------------------------------------------------------------------------–> |
| 20 |
% Outils pour les vecteurs |
| 21 |
%<--------------------------------------------------------------------------–> |
| 22 |
% ce sont des outils élémentaires qui à partir de deux points en définissent |
| 23 |
% un troisième |
| 24 |
% #1 si c'est une option alors c'est un nombre réel |
| 25 |
% #2 et #3 sont deux points |
| 26 |
% #4 est le nom du point qui résulte de la transformation |
| 27 |
% exemple : \tkzVecKNorm (A,B){C} définit un point C tel que AC = 1 et C est % % un point de la droite (AC). #1 peut être négatif |
| 28 |
|
| 29 |
\def\tkzDuplicateSegment(#1,#2)(#3,#4){% |
| 30 |
\begingroup |
| 31 |
\tkz@@CalcLength(#1,#2){tkz@firstlen}% |
| 32 |
\tkz@@CalcLength(#3,#4){tkz@secondlen}% |
| 33 |
\edef\tkz@ratio{\fpeval{\tkz@firstlen/\tkz@secondlen}} |
| 34 |
\tkz@VecKCoLinear[\tkz@ratio](#3,#4,#3)% |
| 35 |
\endgroup |
| 36 |
} |
| 37 |
\let\tkzDuplicateLength\tkzDuplicateSegment |
| 38 |
%<--------------------------------------------------------------------------–> |
| 39 |
% Coordonnées d'un vecteur (couple de points) |
| 40 |
% Deux points A et B donc un vecteur on récupère les coordonnées de v(AB) |
| 41 |
% en cm |
| 42 |
% tkzGetVecCoord en cm ou en pt ??? |
| 43 |
%<--------------------------------------------------------------------------–> |
| 44 |
%result in #3x et #3y #1 et #2 sont les points |
| 45 |
% passage en cm avec fp ? |
| 46 |
% 28.45274 =1 cm |
| 47 |
\def\tkzGetVectxy(#1,#2)#3{% |
| 48 |
\begingroup |
| 49 |
\pgfpointdiff{\pgfpointanchor{#1}{center}}% |
| 50 |
{\pgfpointanchor{#2}{center}}% |
| 51 |
\pgfmathparse{\pgf@sys@tonumber{\pgf@x}/1cm}% |
| 52 |
\let\tkzresultx\pgfmathresult |
| 53 |
\pgfmathparse{\pgf@sys@tonumber{\pgf@y}/1cm}% |
| 54 |
\let\tkzresulty\pgfmathresult |
| 55 |
\global\expandafter\edef\csname #3x\endcsname{\tkzresultx}% |
| 56 |
\global\expandafter\edef\csname #3y\endcsname{\tkzresulty}% |
| 57 |
\endgroup |
| 58 |
} |
| 59 |
%<--------------------------------------------------------------------------–> |
| 60 |
% options #1 two points #2,#3 result in #4 |
| 61 |
% |
| 62 |
%<--------------------------------------------------------------------------–> |
| 63 |
%<--------------------------------------------------------------------------–> |
| 64 |
% tkzDefPointWith |
| 65 |
%<--------------------------------------------------------------------------–> |
| 66 |
\def\tkz@numv{0} |
| 67 |
\pgfkeys{/@pointwith/.cd, |
| 68 |
colinear/.code args = {at #1}{\def\tkz@numv{0}\def\tkz@frompoint{#1}}, |
| 69 |
orthogonal/.code = {\def\tkz@numv{1}}, |
| 70 |
linear/.code = {\def\tkz@numv{2}}, |
| 71 |
orthogonal normed/.code = {\def\tkz@numv{3}}, |
| 72 |
linear normed/.code = {\def\tkz@numv{4}}, |
| 73 |
colinear normed/.code args = {at #1}{\def\tkz@numv{5}\def\tkz@frompoint{#1}}, |
| 74 |
K/.code = {\edef\tkz@coeff{\fpeval{#1}}}, |
| 75 |
K = 1, |
| 76 |
normed/.is if = tkz@line@normed, |
| 77 |
normed/.default = true, |
| 78 |
normed = false, |
| 79 |
orthogonal |
| 80 |
} |
| 81 |
\def\tkzDefPointWith{\pgfutil@ifnextchar[{\tkz@DefPointWith}{\tkz@DefPointWith[]}} |
| 82 |
|
| 83 |
\def\tkz@DefPointWith[#1](#2,#3){% |
| 84 |
\begingroup |
| 85 |
\pgfkeys{/@pointwith/.cd,K=1} |
| 86 |
\pgfqkeys{/@pointwith}{#1} |
| 87 |
\ifcase\tkz@numv% |
| 88 |
% first case 0 |
| 89 |
\tkz@DefVectorColinearat[\tkz@coeff](#2,#3) |
| 90 |
\or% 1 |
| 91 |
\tkz@VecKOrth[\tkz@coeff](#2,#3) |
| 92 |
\or% 2 |
| 93 |
\tkz@VecK[\tkz@coeff](#2,#3) |
| 94 |
\or% 3 |
| 95 |
\tkz@VecKOrthNorm[\tkz@coeff](#2,#3) |
| 96 |
\or% 4 |
| 97 |
\tkz@VecKNorm[\tkz@coeff](#2,#3) |
| 98 |
\or% 5 |
| 99 |
\tkz@VecKColinearNorm[\tkz@coeff](#2,#3) |
| 100 |
\fi |
| 101 |
\endgroup |
| 102 |
} |
| 103 |
%<--------------------------------------------------------------------------–> |
| 104 |
% tkzDefVectorfrom |
| 105 |
%<--------------------------------------------------------------------------–> |
| 106 |
% tkz@numv 0 |
| 107 |
\def\tkz@DefVectorColinearat[#1](#2,#3){% |
| 108 |
\iftkz@line@normed |
| 109 |
\tkz@VecKColinearNorm[#1](#2,#3) |
| 110 |
\else |
| 111 |
\begingroup |
| 112 |
\pgfpointdiff{\pgfpointanchor{#2}{center}}{\pgfpointanchor{#3}{center}}% |
| 113 |
\pgf@xa=\pgf@x\relax% |
| 114 |
\pgf@ya=\pgf@y\relax% |
| 115 |
\pgfinterruptboundingbox |
| 116 |
\path (\tkz@frompoint)--++(\tkz@coeff\pgf@xa,\tkz@coeff\pgf@ya) coordinate (tkzPointResult); |
| 117 |
\endpgfinterruptboundingbox |
| 118 |
\endgroup |
| 119 |
\fi |
| 120 |
} |
| 121 |
%<--------------------------------------------------------------------------–> |
| 122 |
% tkzVector K Orth coeff dans #1 |
| 123 |
% v(AN) perp v(AB) (v(AB) , v(AN) ) sens direct cercle trigo |
| 124 |
% ||v(AN)||=||v(AB)|| |
| 125 |
%<--------------------------------------------------------------------------–> |
| 126 |
% tkz@numv 1 |
| 127 |
\def\tkzVecKOrth{\pgfutil@ifnextchar[{\tkz@VecKOrth}{\tkz@VecKOrth[1]}} |
| 128 |
\def\tkz@VecKOrth[#1](#2,#3){% |
| 129 |
\iftkz@line@normed |
| 130 |
\tkz@VecKOrthNorm[#1](#2,#3) |
| 131 |
\else |
| 132 |
\begingroup |
| 133 |
\pgfpointdiff{\pgfpointanchor{#2}{center}}{\pgfpointanchor{#3}{center}}% |
| 134 |
\pgf@xa=-\pgf@y% |
| 135 |
\pgf@ya=\pgf@x% |
| 136 |
\pgfinterruptboundingbox |
| 137 |
\path (#2)--++(\tkz@coeff\pgf@xa,\tkz@coeff\pgf@ya) coordinate (tkzPointResult); |
| 138 |
\endpgfinterruptboundingbox |
| 139 |
\endgroup |
| 140 |
\fi |
| 141 |
}% |
| 142 |
|
| 143 |
%<--------------------------------------------------------------------------–> |
| 144 |
% v(AN)=#1 x v(AB) |
| 145 |
% #1 le coeff; #2--> A #3--> B #4-->N tq #4-#2 = #1*(#3-#2) |
| 146 |
%<--------------------------------------------------------------------------–> |
| 147 |
% tkz@numv 2 |
| 148 |
\def\tkzVecK{\pgfutil@ifnextchar[{\tkz@VecK}{\tkz@VecK[1]}} |
| 149 |
\def\tkz@VecK[#1](#2,#3){% |
| 150 |
\iftkz@line@normed |
| 151 |
\tkz@VecKNorm[#1](#2,#3) |
| 152 |
\else |
| 153 |
\begingroup |
| 154 |
\pgfpointdiff{\pgfpointanchor{#2}{center}}% |
| 155 |
{\pgfpointanchor{#3}{center}}% |
| 156 |
\pgf@xa=\pgf@x\relax% |
| 157 |
\pgf@ya=\pgf@y\relax% |
| 158 |
\pgfmathparse{#1} |
| 159 |
\let\tkz@coeff\pgfmathresult |
| 160 |
\pgfinterruptboundingbox |
| 161 |
\path (#2)--++(\tkz@coeff\pgf@xa,\tkz@coeff\pgf@ya) coordinate (tkzPointResult); |
| 162 |
\endpgfinterruptboundingbox |
| 163 |
\endgroup |
| 164 |
\fi |
| 165 |
}% |
| 166 |
%<--------------------------------------------------------------------------–> |
| 167 |
% tkzVecKOrthNorm coeff dans #1 |
| 168 |
% v(AN) perp v(AB) v(AB) v(AN) sens direct cercle trigo |
| 169 |
% ||v(AN||=1 si #1 est vide ou =1 sinon ||v(AN||=K |
| 170 |
%<--------------------------------------------------------------------------–> |
| 171 |
% tkz@numv 3 |
| 172 |
\def\tkzVecKOrthNorm{\pgfutil@ifnextchar[{\tkz@VecKOrthNorm}% |
| 173 |
{\tkz@VecKOrthNorm[1]}} |
| 174 |
\def\tkz@VecKOrthNorm[#1](#2,#3){% |
| 175 |
\begingroup |
| 176 |
\tkzpointnormalised{\pgfpointdiff{\pgfpointanchor{#2}{center}}% |
| 177 |
{\pgfpointanchor{#3}{center}}} |
| 178 |
\pgf@xa=-\pgf@y\relax% |
| 179 |
\pgf@ya=\pgf@x\relax% |
| 180 |
\edef\tkz@x{\fpeval{28.45274*(#1)*\pgf@xa}} |
| 181 |
\edef\tkz@y{\fpeval{28.45274*(#1)*\pgf@ya}} |
| 182 |
\pgfinterruptboundingbox |
| 183 |
\path (#2)--++(\tkz@x pt,\tkz@y pt) coordinate (tkzPointResult); |
| 184 |
\endpgfinterruptboundingbox |
| 185 |
\endgroup |
| 186 |
}% |
| 187 |
%<--------------------------------------------------------------------------–> |
| 188 |
% VectorNormalised ou K*VectorNormalised |
| 189 |
% A-->#2 B-->#3 N-->#4 v(AB) devient v(AN) tq ||v(AN)||=1 si #1=1 |
| 190 |
% sinon ||v(AN)||=#1 |
| 191 |
%<--------------------------------------------------------------------------–> |
| 192 |
% tkz@numv 4 |
| 193 |
\def\tkzVecKNorm{\pgfutil@ifnextchar[{\tkz@VecKNorm}{\tkz@VecKNorm[1]}} |
| 194 |
\def\tkz@VecKNorm[#1](#2,#3){% |
| 195 |
\begingroup |
| 196 |
\tkzpointnormalised{% |
| 197 |
\pgfpointdiff{\pgfpointanchor{#2}{center}} |
| 198 |
{\pgfpointanchor{#3}{center}}} |
| 199 |
\pgf@xa=\pgf@x\relax% |
| 200 |
\pgf@ya=\pgf@y\relax% |
| 201 |
\edef\tkz@x{\fpeval{28.45274*(#1)*\pgf@xa}} |
| 202 |
\edef\tkz@y{\fpeval{28.45274*(#1)*\pgf@ya}} |
| 203 |
\pgfinterruptboundingbox |
| 204 |
\path (#2)--++(\tkz@x pt,\tkz@y pt) coordinate (tkzPointResult); |
| 205 |
\endpgfinterruptboundingbox |
| 206 |
\endgroup |
| 207 |
}% |
| 208 |
%<--------------------------------------------------------------------------–> |
| 209 |
% \tkz@VecKColinearNorm |
| 210 |
%<--------------------------------------------------------------------------–> |
| 211 |
%% tkz@numv 5 |
| 212 |
\def\tkz@VecKColinearNorm[#1](#2,#3){% |
| 213 |
\begingroup |
| 214 |
\tkzpointnormalised{% |
| 215 |
\pgfpointdiff{\pgfpointanchor{#2}{center}} |
| 216 |
{\pgfpointanchor{#3}{center}}} |
| 217 |
\pgf@xa=\pgf@x\relax% |
| 218 |
\pgf@ya=\pgf@y\relax% |
| 219 |
\edef\tkz@x{\fpeval{28.45274*(#1)*\pgf@xa}} |
| 220 |
\edef\tkz@y{\fpeval{28.45274*(#1)*\pgf@ya}} |
| 221 |
\pgfinterruptboundingbox |
| 222 |
\path (\tkz@frompoint)--++(\tkz@x pt,\tkz@y pt) coordinate (tkzPointResult); |
| 223 |
\endpgfinterruptboundingbox |
| 224 |
\endgroup |
| 225 |
}% |
| 226 |
%<--------------------------------------------------------------------------–> |
| 227 |
% VecKCoLinear CN = K x AB #1 pt #2 pt #3 pt #4 nb #5 pt result |
| 228 |
% il faut modifier cette macro : on supprime #3 pour la colinéarité |
| 229 |
% Il suffit d'utiliser Replicate ou Duplicate coeff dans #1 |
| 230 |
% v(CD)=#1 x v(AB) #1 le coeff; #2-->A #3-->B #4-->C |
| 231 |
%<--------------------------------------------------------------------------–> |
| 232 |
\def\tkz@VecKCoLinear[#1](#2,#3,#4){% |
| 233 |
\begingroup |
| 234 |
\pgfpointdiff{\pgfpointanchor{#2}{center}}% |
| 235 |
{\pgfpointanchor{#3}{center}}% |
| 236 |
\pgf@xa=\pgf@x\relax% |
| 237 |
\pgf@ya=\pgf@y\relax% |
| 238 |
\edef\tkz@coeff{\fpeval{#1}} |
| 239 |
\pgfinterruptboundingbox |
| 240 |
\path (#4)--+(\tkz@coeff\pgf@xa,\tkz@coeff\pgf@ya) coordinate (tkzPointResult); |
| 241 |
\endpgfinterruptboundingbox |
| 242 |
\endgroup |
| 243 |
}% |
| 244 |
\def\tkz@VecCoLinear(#1,#2,#3){% |
| 245 |
\begingroup |
| 246 |
\pgfpointdiff{\pgfpointanchor{#1}{center}}% |
| 247 |
{\pgfpointanchor{#2}{center}}% |
| 248 |
\pgf@xa=\pgf@x\relax% |
| 249 |
\pgf@ya=\pgf@y\relax% |
| 250 |
\pgfinterruptboundingbox |
| 251 |
\path (#3)--+(\pgf@xa,\pgf@ya) coordinate (tkzPointResult); |
| 252 |
\endpgfinterruptboundingbox |
| 253 |
\endgroup |
| 254 |
}% |
| 255 |
\makeatother |
| 256 |
\endinput |