summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_functions_maths.lua
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_functions_maths.lua')
-rw-r--r--macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_functions_maths.lua41
1 files changed, 19 insertions, 22 deletions
diff --git a/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_functions_maths.lua b/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_functions_maths.lua
index 0702b0a568..63f5190f02 100644
--- a/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_functions_maths.lua
+++ b/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_functions_maths.lua
@@ -1,6 +1,6 @@
-- tkz_elements_functions_maths.lua
--- date 2024/01/16
--- version 1.82c
+-- date 2024/02/04
+-- version 2.00c
-- Copyright 2024 Alain Matthes
-- This work may be distributed and/or modified under the
-- conditions of the LaTeX Project Public License, either version 1.3
@@ -39,10 +39,9 @@ function Cramer22(a1,a2,b1,b2)
end
function aligned ( m,a,b )
- local z,epsilon
- epsilon = 10^(-8)
+ local z
z = (b-a)/(m-b)
- if math.abs(z.im) < epsilon
+ if math.abs(z.im) < tkz_epsilon
then
return true
else
@@ -51,11 +50,9 @@ function aligned ( m,a,b )
end
function islinear (z1,z2,z3)
- local epsilon
local dp
- epsilon = 10^(-8)
dp = (z2-z1) ^ (z3-z1)
- if math.abs(dp) < epsilon
+ if math.abs(dp) < tkz_epsilon
then
return true
else
@@ -64,11 +61,9 @@ function islinear (z1,z2,z3)
end
function isortho (z1,z2,z3)
- local epsilon
local dp
- epsilon = 10^(-8)
dp = (z2-z1) .. (z3-z1)
- if math.abs(dp) < epsilon
+ if math.abs(dp) < tkz_epsilon
then
return true
else
@@ -112,16 +107,13 @@ return angle_normalize_ (a)
end
function angle_normalize_ (a)
-local dblpi
- dblpi = 2 * math.pi
- if a > dblpi
- then
- a = a - dblpi
- end
- if a < 0 then
- a = a + dblpi
- end
- return a
+ while a < 0 do
+ a = a + 2*math.pi
+ end
+ while a >= 2*math.pi do
+ a = a - 2*math.pi
+ end
+ return a
end
function barycenter (...)
@@ -133,4 +125,9 @@ function swap(a,b)
a=b
b=t
return a,b
-end \ No newline at end of file
+end
+
+function format_number(number, decimal_places)
+ local format_string = string.format("%%.%df", decimal_places)
+ return string.format(format_string, number)
+end