diff options
author | Karl Berry <karl@freefriends.org> | 2023-10-26 19:55:40 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-10-26 19:55:40 +0000 |
commit | da78dcc7c347a0ae005553a505795369e476aa45 (patch) | |
tree | 8cf83e3ed14575612913e80a68fd9d766aef15f4 /Master/texmf-dist/tex/latex/tkz-elements/tkz_elements_functions_points.lua | |
parent | 85915ac057e86ac4b2133edb1c7446fbb63628b7 (diff) |
tkz-elements (26oct23)
git-svn-id: svn://tug.org/texlive/trunk@68664 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tkz-elements/tkz_elements_functions_points.lua')
-rw-r--r-- | Master/texmf-dist/tex/latex/tkz-elements/tkz_elements_functions_points.lua | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/tkz-elements/tkz_elements_functions_points.lua b/Master/texmf-dist/tex/latex/tkz-elements/tkz_elements_functions_points.lua new file mode 100644 index 00000000000..fcd249d8916 --- /dev/null +++ b/Master/texmf-dist/tex/latex/tkz-elements/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 |