-- tkz_elements_points.lua
-- 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
-- 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
