From 06c5912f02baca5550fb046b23b38d7b08dd3b34 Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Sun, 12 Sep 2021 13:14:40 -0400 Subject: [PATCH] doc tweaks speedup tweak for _general_line_intersection restore older faster is_polygon_clockwise bugfix polygon_normal --- geometry.scad | 50 ++++++++++++++++++++++++++++++-------------------- threading.scad | 2 +- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/geometry.scad b/geometry.scad index a31c5c1..52b12a3 100644 --- a/geometry.scad +++ b/geometry.scad @@ -159,16 +159,15 @@ function line_normal(p1,p2) = // it returns undef. function _general_line_intersection(s1,s2,eps=EPSILON) = let( - denominator = det2([s1[0],s2[0]]-[s1[1],s2[1]]) + denominator = cross(s1[0]-s1[1],s2[0]-s2[1]) ) approx(denominator,0,eps=eps) ? undef : let( - t = det2([s1[0],s2[0]]-s2) / denominator, - u = det2([s1[0],s1[0]]-[s2[0],s1[1]]) / denominator + t = cross(s1[0]-s2[0],s2[0]-s2[1]) / denominator, + u = cross(s1[0]-s2[0],s1[0]-s1[1]) / denominator ) [s1[0]+t*(s1[1]-s1[0]), t, u]; - - + // Function: line_intersection() // Usage: @@ -1308,7 +1307,7 @@ function polygon_normal(poly) = cross(poly[(i+1)%L]-poly[0], poly[(i+2)%L]-poly[(i+1)%L])]) ) - area_vec==0 ? undef : unit(-area_vec); + norm(area_vec)