diff options
author | Karl Berry <karl@freefriends.org> | 2024-01-16 21:29:12 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-01-16 21:29:12 +0000 |
commit | 076968e12d60e0cf6bfb65612dee786d49d3a0cb (patch) | |
tree | 6610904708c77fc0fb7ac99eace088d1d2f0586f /Master/texmf-dist/tex/latex/tkz-elements/tkz_elements_functions_circles.lua | |
parent | 67f9344098e309a9414bbe29f7e8de16b8bb47a7 (diff) |
tkz-elements (16jan24)
git-svn-id: svn://tug.org/texlive/trunk@69461 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tkz-elements/tkz_elements_functions_circles.lua')
-rw-r--r-- | Master/texmf-dist/tex/latex/tkz-elements/tkz_elements_functions_circles.lua | 81 |
1 files changed, 48 insertions, 33 deletions
diff --git a/Master/texmf-dist/tex/latex/tkz-elements/tkz_elements_functions_circles.lua b/Master/texmf-dist/tex/latex/tkz-elements/tkz_elements_functions_circles.lua index cde3c027ac0..33477340d3d 100644 --- a/Master/texmf-dist/tex/latex/tkz-elements/tkz_elements_functions_circles.lua +++ b/Master/texmf-dist/tex/latex/tkz-elements/tkz_elements_functions_circles.lua @@ -1,7 +1,7 @@ -- tkz_elements_functions_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. @@ -51,40 +51,55 @@ function inversion_ (c,p,pt) local r = (ry*ry)/d return c+polar_ (r,point.arg(pt-c)) end - + +function circles_position_ (c1,r1,c2,r2) + local d,max,min,epsilon + epsilon = 10^(-12) + d = point.mod(c1-c2) + max = r1+r2 + min = math.abs ( r1 - r2) + if d > max then return "outside" + elseif math.abs(d - max) < epsilon then return "outside tangent" -- epsilon + elseif math.abs(d - min) < epsilon then return "inside tangent" -- epsilon + elseif d < min then return "inside" + else return "intersect" + end +end + function radical_axis_ (c1,p1,c2,p2) - local d,m,m1,m2,epsilon,ci,cj,ck,cm,cn,r1,r2,t + local ci,cj r1 = point.abs(c1-p1) r2 = point.abs(c2-p2) - epsilon = 10^(-12) - d = point.abs (c2 - c1) - m = d - (r1+r2) - m1 = math.abs (d - (r1+r2)) - m2 = math.abs (d - math.abs(r1-(r2))) - if m2 < epsilon then - ci = rotation_ (p1,math.pi/2,c2) - cj = rotation_ (p1,-math.pi/2,c2) - return ci,cj - elseif m1 < epsilon then -- circles tangent - -- z.A = point : new ( x , y ) contact - t,t = intersection_cc_ (c1,p1,c2,p2) - ci = rotation_ (t,math.pi/2,c2) - cj = rotation_ (t,-math.pi/2,c2) - return ci,cj - -- circles disjoints - elseif m > 0 then - ck = rotation_ (c1,math.pi/3,c2) - ci,cj = intersection_cc_ (c1,p1,ck,c1) - cm,cn = intersection_cc_ (c2,p2,ck,c1) - ci = intersection_ll_ (ci,cj,cm,cn) - cj = symmetry_axial_ (c1,c2,ci) -- projection_ (c1,c2,ci) - return ci,cj - else - ci,cj = intersection_cc_ (c1,p1,c2,p2) - return ci,cj - end + d = point.abs(c1-c2) + h = (r1*r1-r2*r2+d*d)/(2*d) + ck = radical_center_ (c1,p1,c2,p2) + cj = rotation_ (ck,-math.pi/2,c1) + ci = symmetry_ (ck,cj) + return cj,ci end +function radical_center_ (c1,p1,c2,p2) + local d,r1,r2,h + r1 = point.abs(c1-p1) + r2 = point.abs(c2-p2) + d = point.abs(c1-c2) + h = (r1*r1-r2*r2+d*d)/(2*d) + return h*(c2-c1)/d+c1 +end + +-- version 1.60 center pour deux cercles ? +function radical_center3 (C1,C2,C3) + local t1,t2,t3,t4 + t1,t2 = radical_axis_ (C1.center,C1.through,C2.center,C2.through) + if C3 == nil then + return intersection_ll_ (t1,t2,C1.center,C2.center) + else + t3,t4 = radical_axis_ (C3.center,C3.through,C2.center,C2.through) +return intersection_ll_ (t1,t2,t3,t4) +end +end + + function south_pole_ (c,p) local r r = point.abs (c-p) @@ -117,7 +132,7 @@ end -- version 1.60 new function midcircle_(C1,C2) local state,r,s,t1,t2,T1,T2,p,a,b,c,d,Cx,Cy,i,j - state = circles_position(C1,C2) + state = circles_position_(C1.center,C1.radius,C2.center,C2.radius) i = barycenter_ ({C2.center,C1.radius},{C1.center,-C2.radius}) j = barycenter_ ({C2.center,C1.radius},{C1.center,C2.radius}) t1,t2 = tangent_from_ (C1.center,C1.through,i) |