diff options
Diffstat (limited to 'macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_lines.lua')
-rw-r--r-- | macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_lines.lua | 81 |
1 files changed, 50 insertions, 31 deletions
diff --git a/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_lines.lua b/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_lines.lua index 05d4196938..11d8f49d41 100644 --- a/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_lines.lua +++ b/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_lines.lua @@ -1,6 +1,6 @@ -- tkz_elements_lines.lua --- date 2023/10/20 --- version 1.00b +-- date 2023/11/10 +-- version 1.20b -- 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 @@ -34,9 +34,47 @@ function line: new(za, zb) setmetatable(new_line, {__index = line}) return new_line end + +------------------- +-- Result -> real +------------------- +function line: distance (pt) + return point.mod(projection(self,pt)-pt) +end + +function line: slope () + return slope_(self.pa,self.pb) +end +------------------- +-- Result -> boolean +------------------- +function line: in_out (pt) + local sc,epsilon + epsilon = 10^(-12) + sc = math.abs ((pt-self.pa)^(pt-self.pb)) + if sc <= epsilon + then + return true + else + return false + end +end + ------------------- -- Result -> point ------------------- +function line: translation ( pt ) + return translation_ ( self.pb-self.pa,pt ) +end + +function line: set_translation ( ...) + return set_translation_ ( self.pb-self.pa,... ) +end + +function line: projection ( pt ) + return projection_ ( self.pa,self.pb,pt ) +end + function line: set_projection (...) local tp = table.pack(...) local i @@ -60,7 +98,7 @@ function line: set_symmetry_axial (...) end return table.unpack ( t ) end --- k_div ig "gold" or "phi" then + function line: barycenter (ka,kb) return barycenter_({self.pa,ka},{self.pb,kb}) @@ -89,6 +127,14 @@ end function line: gold_ratio() return self.pa + (self.pb-self.pa)*tkzinvphi end + +function line: normalize () + return self.pa+(self.pb-self.pa)/point.mod(self.pb-self.pa) +end + +function line: normalize_inv () + return normalize_ (self.pb,self.pa) +end ------------------- -- Result -> line ------------------- @@ -100,10 +146,6 @@ function line: ortho_from ( pt ) return line : new (pt,pt+(self.pb-self.pa)*point(0,1)) end -function line: projection ( pt ) - return projection_ ( self.pa,self.pb,pt ) -end - function line: mediator () local m m = midpoint_ (self.pa,self.pb) @@ -119,30 +161,7 @@ end function line: circle_swap () return circle : new (self.pb,self.pa) end -------------------- --- Result -> real -------------------- -function line: distance (pt) - return point.mod(projection(self,pt)-pt) -end -------------------- --- Result -> boolean -------------------- -function line: in_out (pt) - local sc,epsilon - epsilon = 10^(-12) - sc = math.abs ((pt-self.pa)^(pt-self.pb)) - if sc <= epsilon - then - return true - else - return false - end -end - -function line: slope () - return slope_(self.pa,self.pb) -end + ---------------------- -- Result -> triangle ---------------------- |