mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Make circle_point_tangents() behavior consistent for points on the circle. Fix #408
This commit is contained in:
parent
a2d0ed6a57
commit
ba32041b53
2 changed files with 5 additions and 2 deletions
|
@ -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]
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue