diff --git a/geometry.scad b/geometry.scad index 52f03c2..280a4fd 100644 --- a/geometry.scad +++ b/geometry.scad @@ -1508,7 +1508,7 @@ function circle_point_tangents(r, d, cp, pt) = dist = norm(delta), baseang = atan2(delta.y,delta.x) ) dist < r? [] : - approx(dist,r)? [[baseang, pt]] : + approx(dist,r)? [pt] : let( relang = acos(r/dist), angs = [baseang + relang, baseang - relang] diff --git a/tests/test_geometry.scad b/tests/test_geometry.scad index 6dc8e02..fbcf4de 100644 --- a/tests/test_geometry.scad +++ b/tests/test_geometry.scad @@ -606,7 +606,10 @@ module test_circle_point_tangents() { [[0,0], 50, [50*sqrt(2),0], [polar_to_xy(50,45), polar_to_xy(50,-45)]], [[5,10], 50, [5+50*sqrt(2),10], [[5,10]+polar_to_xy(50,45), [5,10]+polar_to_xy(50,-45)]], [[0,0], 50, [0,50*sqrt(2)], [polar_to_xy(50,135), polar_to_xy(50,45)]], - [[5,10], 50, [5,10+50*sqrt(2)], [[5,10]+polar_to_xy(50,135), [5,10]+polar_to_xy(50,45)]] + [[5,10], 50, [5,10+50*sqrt(2)], [[5,10]+polar_to_xy(50,135), [5,10]+polar_to_xy(50,45)]], + [[5,10], 50, [5,10+50*sqrt(2)], [[5,10]+polar_to_xy(50,135), [5,10]+polar_to_xy(50,45)]], + [[5,10], 50, [5, 60], [[5, 60]]], + [[5,10], 50, [5, 59], []], ]; for (v = testvals) { cp = v[0]; r = v[1]; pt = v[2]; expect = v[3];