summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_points.lua
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_points.lua')
-rw-r--r--macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_points.lua98
1 files changed, 98 insertions, 0 deletions
diff --git a/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_points.lua b/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_points.lua
new file mode 100644
index 0000000000..bcaff010cc
--- /dev/null
+++ b/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_points.lua
@@ -0,0 +1,98 @@
+-- tkz_elements_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.
+
+-- ----------------------------------------------------------------
+-- points create
+-- ----------------------------------------------------------------
+
+function point: new ( a,b )
+ return scale * point (a,b )
+end
+
+function point: polar ( radius, phi )
+ return scale * polar_ ( radius, phi )
+end
+
+function point: polar_deg ( radius, phi )
+ return scale * polar_ ( radius, phi * math.pi/180 )
+end
+
+function point: north(d)
+ local d = d or 1
+ return self+ polar_ ( d, math.pi/2 )
+end
+
+function point: south(d)
+ local d = d or 1
+ return self + polar_ ( d, -math.pi/2 )
+ end
+
+function point: east(d)
+ local d = d or 1
+ return self+ point( d, 0 )
+end
+
+function point: west(d)
+ local d = d or 1
+ return self + point ( -d, 0 )
+ end
+-- ----------------------------------------------------------------
+-- transformations
+-- ----------------------------------------------------------------
+function point: symmetry(pt)
+ return symmetry_ (self ,pt)
+end
+
+function point: set_symmetry (...)
+ local tp = table.pack(...)
+ local i
+ local t = {}
+ for i=1,tp.n do
+ table.insert( t , symmetry_ (self , tp[i]) )
+ end
+ return table.unpack ( t )
+end
+
+function point: rotation(angle , pt)
+ return rotation_(self,angle,pt)
+end
+
+function point:set_rotation (angle,...)
+ local tp = table.pack(...)
+ local i
+ local t = {}
+ for i=1,tp.n do
+ table.insert( t , rotation_ (self,angle , tp[i]) )
+ end
+ return table.unpack ( t )
+end
+
+function point: homothety(t,pt)
+ return homothety_(self,t,pt)
+end
+
+function point: set_homothety (coeff,...)
+ local tp = table.pack(...)
+ local i
+ local t = {}
+ for i=1,tp.n do
+ table.insert( t , homothety_ (self, coeff , tp[i]) )
+ end
+ return table.unpack ( t )
+end
+
+function point: normalize()
+ local d = point.abs(self)
+ return point(self.re/d,self.im/d)
+end