summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_circle.lua
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_circle.lua')
-rw-r--r--macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_circle.lua82
1 files changed, 59 insertions, 23 deletions
diff --git a/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_circle.lua b/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_circle.lua
index e81609f6ee..ae257221f4 100644
--- a/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_circle.lua
+++ b/macros/latex/contrib/tkz/tkz-elements/latex/tkz_elements_circle.lua
@@ -1,7 +1,7 @@
-- tkz_elements-circles.lua
--- date 23/12/24
--- version 1.72c
--- Copyright 2023 Alain Matthes
+-- date 2024/01/16
+-- version 1.82c
+-- Copyright 2024 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.
@@ -17,9 +17,8 @@
circle = {}
function circle: new (c, t) -- c --> center t --> through
local type = 'circle'
- local ra = line :new (c,t)
- local anti = antipode_ (c,t)
- local di = line : new (anti, t)
+ local ct = line :new (c,t)
+ local opp = antipode_ (c,t)
local radius = point.abs ( c - t )
local south = c - point (0,radius)
local east = c + point (radius,0)
@@ -27,8 +26,8 @@ function circle: new (c, t) -- c --> center t --> through
local west = c - point (radius,0)
local o = { center = c,
through = t,
- ra = ra,
- di = di,
+ ct = ct,
+ opp = opp,
radius = radius,
south = south,
east = east,
@@ -75,18 +74,11 @@ function circle: in_out_disk (pt)
end
end
-function circles_position (C1,C2)
- local d,max,min
- d = point.mod(C1.center-C2.center)
- max = C1.radius + C2.radius
- min = math.abs ( C1.radius - C2.radius)
- if d > max then return "outside"
- elseif d == max then return "outside tangent" -- epsilon
- elseif d == min then return "inside tangent" -- epsilon
- elseif d < min then return "inside"
- else return "intersect"
- end
+-- new version 1.80 added
+function circle : circles_position (C)
+ return circles_position_ (self.center,self.radius,C.center,C.radius)
end
+
-----------------------
-- real --
-----------------------
@@ -122,7 +114,7 @@ function circle: point (t)
return rotation_ (self.center,phi,self.through)
end
-function circle: random_pt(lower, upper)
+function circle: random_pt (lower, upper)
local t
math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)) )
phi = lower + math.random() * (upper - lower)
@@ -136,6 +128,21 @@ end
function circle: external_similitude (C)
return external_similitude_ (self.center,self.radius,C.center,C.radius)
end
+
+function circle : common_tangent(C)
+ local o,s1,s2,t1,t2
+ o = external_similitude_ (self.center,self.radius,C.center,C.radius)
+
+ if self.radius < C.radius then
+ t1,t2 = tangent_from_ (C.center,C.through,o)
+ s1,s2 = tangent_from_ (self.center,self.through,o)
+ return s1,t1,t2,s2
+ else
+ s1,s2 = tangent_from_ (C.center,C.through,o)
+ t1,t2 = tangent_from_ (self.center,self.through,o)
+ return s1,t1,t2,s2
+ end
+end
-----------------------
-- lines --
-----------------------
@@ -148,12 +155,41 @@ function circle: tangent_from (pt)
t1,t2 = tangent_from_ (self.center,self.through,pt)
return line :new (pt,t1),line : new (pt,t2)
end
-
+ -- version 1.80
function circle: radical_axis (C)
local t1,t2
+ if self.radius > C.radius then
t1,t2 = radical_axis_ (self.center,self.through,C.center,C.through)
- return line : new (t1,t2)
+ else
+ t1,t2 = radical_axis_ (C.center,C.through,self.center,self.through)
end
+ return line :new (t1,t2)
+ end
+
+ -- version 1.80
+function circle: radical_center (C1,C2)
+if C2 == nil then
+ if self.radius > C1.radius then
+ return radical_center_ (self.center,self.through,C1.center,C1.through)
+ else
+ return radical_center_ (C1.center,C1.through,self.center,self.through)
+ end
+else
+ return radical_center3 (self,C1,C2)
+end
+end
+ -- version 1.80
+function circle : radical_circle (C1,C2)
+ local rc
+ if C2 == nil then
+ rc = self : radical_center (C1)
+ return self : orthogonal_from (rc)
+ else
+ rc = self : radical_center (C1,C2)
+ return C1 : orthogonal_from (rc)
+ end
+end
+
-- version 1.60 new
function circle : external_tangent(C)
local i,t1,t2,k,T1,T2
@@ -230,7 +266,7 @@ function circle: inversion (...)
else
t = {}
for i=1,tp.n do
- table.insert( t , inversion_ (self.center,self.through , tp[i]) )
+ table.insert( t , inversion_ (self.center,self.through , tp[i]) )
end
return table.unpack ( t )
end