diff options
Diffstat (limited to 'macros/latex/contrib/tkz/tkz-euclide/latex/tools-lua/tkz-tools-lua-math.tex')
-rw-r--r-- | macros/latex/contrib/tkz/tkz-euclide/latex/tools-lua/tkz-tools-lua-math.tex | 113 |
1 files changed, 3 insertions, 110 deletions
diff --git a/macros/latex/contrib/tkz/tkz-euclide/latex/tools-lua/tkz-tools-lua-math.tex b/macros/latex/contrib/tkz/tkz-euclide/latex/tools-lua/tkz-tools-lua-math.tex index 1a0491d599..67db5197aa 100644 --- a/macros/latex/contrib/tkz/tkz-euclide/latex/tools-lua/tkz-tools-lua-math.tex +++ b/macros/latex/contrib/tkz/tkz-euclide/latex/tools-lua/tkz-tools-lua-math.tex @@ -10,105 +10,15 @@ % This work has the LPPL maintenance status “maintained”. % The Current Maintainer of this work is Alain Matthes. -\def\fileversion{5.00c} -\def\filedate{2023/01/23} -\typeout{2023/01/23 5.00c tkz-tools-lua-math.tex} +\def\fileversion{5.01c} +\def\filedate{2023/01/24} +\typeout{2023/01/24 5.01c tkz-tools-lua-math.tex} \makeatletter %<--------------------------------------------------------------------------> %<--------------------------------------------------------------------------> % Lengths %<--------------------------------------------------------------------------> %<--------------------------------------------------------------------------> -\begin{luacode*} -complex = {} -- global complex numbers registry -M = {} -- the module -local mt = {} --metatable for complex numbers -setmetatable(_ENV, {__index = complex}) - function new (r, i) - local cp = {} - cp = {r=r, i=i} - return setmetatable(cp,mt) - end - M.new = new -- add 'new' to the module - -- create constant 'i' - M.i = new(0, 1) - - function M.add (c1, c2) - return new(c1.r + c2.r, c1.i + c2.i) - end - - function M.sub (c1, c2) - return new(c1.r - c2.r, c1.i - c2.i) - end - - function M.mul (c1, c2) - return new(c1.r*c2.r - c1.i*c2.i, c1.r*c2.i + c1.i*c2.r) - end - - function M.inv (c) - local n = c.r^2 + c.i^2 - return new(c.r/n, -c.i/n) - end - - function M.div (c1, c2) - return M.mul(c1, M.inv(c2)) - end - - function M.re (c) - return new(c.r,0) - end - - function M.im (c) - return new(c.i,0) - end - - function M.mod (c) - local n = c.r^2 + c.i^2 - return new(n,0) - end - - function M.prinarg(c) - local arg - if c.r > 0 then - arg = math.atan(c.i/c.r) - elseif c.r < 0 and c.i >= 0 then - arg = math.atan(c.i/c.r) + math.pi - elseif c.r < 0 and c.i < 0 then - arg = math.atan(c.i/c.r) - math.pi - elseif c.r == 0 and c.i > 0 then - arg = math.pi / 2 - elseif c.r == 0 and c.i < 0 then - arg = - math.pi / 2 - else - error("Principal argument not defined.") - end - return arg - end - - function M.op (...) - return ... - end - - function M.tostring (c) - if c.i ==0 then - return string.format("%g", c.r) - elseif c.i> 0 and c.i==1 then - return string.format("%g+i", c.r) - elseif c.i> 0 and c.i~=1 then - return string.format("%g+%gi", c.r, c.i) - else - return string.format("%g%gi", c.r, c.i) --to avoid +- - end - end - - --Setting Metatable operations. - mt.__add = M.add - mt.__mul = M.mul - mt.__sub = M.sub - mt.__tostring = M.tostring -\end{luacode*} - - \begin{luacode*} function normalize(angleA,angleB) @@ -144,15 +54,6 @@ function tkzround(nb, ND) end \end{luacode*} -\newcommand\cpxNew[2]{% -\directlua{complex[\luastringN{#1}] = M.new(#2)}} -\newcommand\cpxPrint[1]{% -\directlua{tex.sprint(tostring(complex[\luastringN{#1}]))}} -\newcommand\cpxAdd[3]{% -\directlua{complex[\luastringN{#1}]% - =M.add(complex[\luastringN{#2}],complex[\luastringN{#3}])}} - - \def\tkz@Dec#1{% \directlua{tex.print(string.format('\@percentchar.6f',#1))} } @@ -188,16 +89,8 @@ end \let\tkzLog\tkz@Log \let\tkzSin\tkz@Sin \let\tkzCos\tkz@Cos -% \tkzpointnormalised# -% tkzCalcLength -% \tkzGetLength -% \tkzpttocm -% \tkzcmtopt -% \tkzFindSlope -% option xfp % \tkzpointnormalised normalise un point A-->A' tq ||v(OA')=1|| -% équivalent de \pgfpointnormalised avec fp % example % \tkzpointnormalised{% % \pgfpointdiff{\pgfpointanchor{A}{center}} |