diff options
author | Norbert Preining <norbert@preining.info> | 2023-10-27 03:03:08 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-10-27 03:03:08 +0000 |
commit | e7c703c953f148411c70d5ca86dc1c1023d73806 (patch) | |
tree | 103695d0d26aa0b1d5b1942fd433cf5f9a90d47f /macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_functions_points.lua | |
parent | 721b0492f150d59f61b504ab803c7ef1a9a67a0b (diff) |
CTAN sync 202310270303
Diffstat (limited to 'macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_functions_points.lua')
-rw-r--r-- | macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_functions_points.lua | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_functions_points.lua b/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_functions_points.lua new file mode 100644 index 0000000000..fcd249d891 --- /dev/null +++ b/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_functions_points.lua @@ -0,0 +1,81 @@ +-- tkz_elements_functions_points.lua +-- date 2023/10/20 +-- version 1.00b +-- Copyright 2023 Alain Matthes +-- This work may be distributed and/or modified under the +-- conditions of the LaTeX Project Public License, either version 1.3 +-- of this license or (at your option) any later version. +-- The latest version of this license is in +-- http://www.latex-project.org/lppl.txt +-- and version 1.3 or later is part of all distributions of LaTeX +-- version 2005/12/01 or later. +-- This work has the LPPL maintenance status “maintained”. +-- The Current Maintainer of this work is Alain Matthes. + +function id () +for i,k in pairs(z) do + if _G[i]==k then else _G[i]=k end + end +end + +function polar_ (radius, phi) + return point(radius * math.cos(phi), radius * math.sin(phi)) +end + +function barycenter_ (...) +local cp = table.pack(...) +local i +local sum = 0 +local weight=0 +for i=1,cp.n do + sum = sum + cp[i][1]*cp[i][2] + weight = weight + cp[i][2] +end +return sum/weight +end + +function rotation_ (center,alpha,pt) + local z = point( math.cos(alpha) , math.sin(alpha) ) + return z*(pt-center)+center +end + +function symmetry_(c,pt) + return 2 * c - pt +end + +function homothety_(c,t,p) + return c + t * (p - c) +end + +function translation_(a , p) + return a+p +end + +function set_translation_ (u,...) + local tp = table.pack(...) + local i + local t = {} + for i=1,tp.n do + table.insert( t , (u + tp[i]) ) + end + return table.unpack ( t ) +end + +function random_point(lower, upper) + math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)) ) + x = math.random (lower, upper) + y = math.random (lower, upper) + return scale * point (x,y) +end + +function midpoints_ (...) + local arg = table.pack(...) + local n = arg.n + local i + local t = {} + for i=1, n-1 do + table.insert( t , (arg[i]+arg[i+1])/2 ) + end + table.insert( t , (arg[n]+arg[1])/2 ) + return table.unpack ( t ) +end
\ No newline at end of file |