diff --git a/geometry.scad b/geometry.scad index 7cda463..561e6a2 100644 --- a/geometry.scad +++ b/geometry.scad @@ -1003,10 +1003,10 @@ function plane_point_nearest_origin(plane) = // Description: // Given a plane as [A,B,C,D] where the cartesian equation for that plane // is Ax+By+Cz=D, determines how far from that plane the given point is. -// The returned distance will be positive if the point is in front of the -// plane; on the same side of the plane as the normal of that plane points -// towards. If the point is behind the plane, then the distance returned -// will be negative. The normal of the plane is the same as [A,B,C]. +// The returned distance will be positive if the point is above the +// plane, meaning on the side where the plane normal points. +// If the point is below the plane, then the distance returned +// will be negative. The normal of the plane is [A,B,C]. // Arguments: // plane = The `[A,B,C,D]` plane definition where `Ax+By+Cz=D` is the formula of the plane. // point = The distance evaluation point. @@ -1049,7 +1049,7 @@ function normalize_plane(plane) = // Topics: Geometry, Planes, Lines, Angle // Description: // Compute the angle between a plane [A, B, C, D] and a 3d line, specified as a pair of 3d points [p1,p2]. -// The resulting angle is signed, with the sign positive if the vector p2-p1 lies on +// The resulting angle is signed, with the sign positive if the vector p2-p1 lies above the plane, on // the same side of the plane as the plane's normal vector. function plane_line_angle(plane, line) = assert( _valid_plane(plane), "Invalid plane." ) @@ -1226,7 +1226,7 @@ function points_on_plane(points, plane, eps=EPSILON) = _pointlist_greatest_distance(points,plane) < eps; -// Function: in_front_of_plane() +// Function: above_plane() // Usage: // test = in_front_of_plane(plane, point); // Topics: Geometry, Planes @@ -1238,7 +1238,7 @@ function points_on_plane(points, plane, eps=EPSILON) = // Arguments: // plane = The [A,B,C,D] coefficients for the first plane equation `Ax+By+Cz=D`. // point = The 3D point to test. -function in_front_of_plane(plane, point) = +function above_plane(plane, point) = point_plane_distance(plane, point) > EPSILON; diff --git a/hull.scad b/hull.scad index 4adb7c3..8371021 100644 --- a/hull.scad +++ b/hull.scad @@ -186,7 +186,7 @@ function hull3d_faces(points) = remaining = [for (i = [0:1:len(points)-1]) if (i!=a && i!=b && i!=c && i!=d) i], // Build an initial tetrahedron. // Swap b, c if d is in front of triangle t. - ifop = in_front_of_plane(plane, points[d]), + ifop = above_plane(plane, points[d]), bc = ifop? [c,b] : [b,c], b = bc[0], c = bc[1], diff --git a/tests/test_geometry.scad b/tests/test_geometry.scad index 2c19e6d..ae124fe 100644 --- a/tests/test_geometry.scad +++ b/tests/test_geometry.scad @@ -51,7 +51,7 @@ test_polygon_line_intersection(); test_plane_intersection(); test_coplanar(); test_points_on_plane(); -test_in_front_of_plane(); +test_above_plane(); test_circle_2tangents(); test_circle_3points(); test_circle_point_tangents(); @@ -754,17 +754,17 @@ module test_coplanar() { *test_coplanar(); -module test_in_front_of_plane() { +module test_above_plane() { plane = plane3pt([0,0,0], [0,10,10], [10,0,10]); - assert(in_front_of_plane(plane, [5,5,10]) == false); - assert(in_front_of_plane(plane, [-5,0,0]) == true); - assert(in_front_of_plane(plane, [5,0,0]) == false); - assert(in_front_of_plane(plane, [0,-5,0]) == true); - assert(in_front_of_plane(plane, [0,5,0]) == false); - assert(in_front_of_plane(plane, [0,0,5]) == true); - assert(in_front_of_plane(plane, [0,0,-5]) == false); + assert(above_plane(plane, [5,5,10]) == false); + assert(above_plane(plane, [-5,0,0]) == true); + assert(above_plane(plane, [5,0,0]) == false); + assert(above_plane(plane, [0,-5,0]) == true); + assert(above_plane(plane, [0,5,0]) == false); + assert(above_plane(plane, [0,0,5]) == true); + assert(above_plane(plane, [0,0,-5]) == false); } -*test_in_front_of_plane(); +*test_above_plane(); module test_is_path() { @@ -808,7 +808,7 @@ module test_polygon_area() { assert(approx(polygon_area(circle(r=50,$fn=1000),signed=true), -PI*50*50, eps=0.1)); assert(approx(polygon_area(rot([13,27,75], p=path3d(circle(r=50,$fn=1000),fill=23)), - signed=true), -PI*50*50, eps=0.1)); + signed=true), PI*50*50, eps=0.1)); assert(abs(triangle_area([0,0], [0,10], [10,0]) + 50) < EPSILON); assert(abs(triangle_area([0,0], [0,10], [0,15])) < EPSILON); assert(abs(triangle_area([0,0], [10,0], [0,10]) - 50) < EPSILON);