mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
fix tests, rename in_front_of_plane to above_plane
This commit is contained in:
parent
566d9b4ece
commit
2a2458577b
3 changed files with 19 additions and 19 deletions
|
@ -1003,10 +1003,10 @@ function plane_point_nearest_origin(plane) =
|
||||||
// Description:
|
// Description:
|
||||||
// Given a plane as [A,B,C,D] where the cartesian equation for that plane
|
// 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.
|
// 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
|
// The returned distance will be positive if the point is above the
|
||||||
// plane; on the same side of the plane as the normal of that plane points
|
// plane, meaning on the side where the plane normal points.
|
||||||
// towards. If the point is behind the plane, then the distance returned
|
// If the point is below the plane, then the distance returned
|
||||||
// will be negative. The normal of the plane is the same as [A,B,C].
|
// will be negative. The normal of the plane is [A,B,C].
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// plane = The `[A,B,C,D]` plane definition where `Ax+By+Cz=D` is the formula of the plane.
|
// plane = The `[A,B,C,D]` plane definition where `Ax+By+Cz=D` is the formula of the plane.
|
||||||
// point = The distance evaluation point.
|
// point = The distance evaluation point.
|
||||||
|
@ -1049,7 +1049,7 @@ function normalize_plane(plane) =
|
||||||
// Topics: Geometry, Planes, Lines, Angle
|
// Topics: Geometry, Planes, Lines, Angle
|
||||||
// Description:
|
// Description:
|
||||||
// Compute the angle between a plane [A, B, C, D] and a 3d line, specified as a pair of 3d points [p1,p2].
|
// 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.
|
// the same side of the plane as the plane's normal vector.
|
||||||
function plane_line_angle(plane, line) =
|
function plane_line_angle(plane, line) =
|
||||||
assert( _valid_plane(plane), "Invalid plane." )
|
assert( _valid_plane(plane), "Invalid plane." )
|
||||||
|
@ -1226,7 +1226,7 @@ function points_on_plane(points, plane, eps=EPSILON) =
|
||||||
_pointlist_greatest_distance(points,plane) < eps;
|
_pointlist_greatest_distance(points,plane) < eps;
|
||||||
|
|
||||||
|
|
||||||
// Function: in_front_of_plane()
|
// Function: above_plane()
|
||||||
// Usage:
|
// Usage:
|
||||||
// test = in_front_of_plane(plane, point);
|
// test = in_front_of_plane(plane, point);
|
||||||
// Topics: Geometry, Planes
|
// Topics: Geometry, Planes
|
||||||
|
@ -1238,7 +1238,7 @@ function points_on_plane(points, plane, eps=EPSILON) =
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// plane = The [A,B,C,D] coefficients for the first plane equation `Ax+By+Cz=D`.
|
// plane = The [A,B,C,D] coefficients for the first plane equation `Ax+By+Cz=D`.
|
||||||
// point = The 3D point to test.
|
// point = The 3D point to test.
|
||||||
function in_front_of_plane(plane, point) =
|
function above_plane(plane, point) =
|
||||||
point_plane_distance(plane, point) > EPSILON;
|
point_plane_distance(plane, point) > EPSILON;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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],
|
remaining = [for (i = [0:1:len(points)-1]) if (i!=a && i!=b && i!=c && i!=d) i],
|
||||||
// Build an initial tetrahedron.
|
// Build an initial tetrahedron.
|
||||||
// Swap b, c if d is in front of triangle t.
|
// 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],
|
bc = ifop? [c,b] : [b,c],
|
||||||
b = bc[0],
|
b = bc[0],
|
||||||
c = bc[1],
|
c = bc[1],
|
||||||
|
|
|
@ -51,7 +51,7 @@ test_polygon_line_intersection();
|
||||||
test_plane_intersection();
|
test_plane_intersection();
|
||||||
test_coplanar();
|
test_coplanar();
|
||||||
test_points_on_plane();
|
test_points_on_plane();
|
||||||
test_in_front_of_plane();
|
test_above_plane();
|
||||||
test_circle_2tangents();
|
test_circle_2tangents();
|
||||||
test_circle_3points();
|
test_circle_3points();
|
||||||
test_circle_point_tangents();
|
test_circle_point_tangents();
|
||||||
|
@ -754,17 +754,17 @@ module test_coplanar() {
|
||||||
*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]);
|
plane = plane3pt([0,0,0], [0,10,10], [10,0,10]);
|
||||||
assert(in_front_of_plane(plane, [5,5,10]) == false);
|
assert(above_plane(plane, [5,5,10]) == false);
|
||||||
assert(in_front_of_plane(plane, [-5,0,0]) == true);
|
assert(above_plane(plane, [-5,0,0]) == true);
|
||||||
assert(in_front_of_plane(plane, [5,0,0]) == false);
|
assert(above_plane(plane, [5,0,0]) == false);
|
||||||
assert(in_front_of_plane(plane, [0,-5,0]) == true);
|
assert(above_plane(plane, [0,-5,0]) == true);
|
||||||
assert(in_front_of_plane(plane, [0,5,0]) == false);
|
assert(above_plane(plane, [0,5,0]) == false);
|
||||||
assert(in_front_of_plane(plane, [0,0,5]) == true);
|
assert(above_plane(plane, [0,0,5]) == true);
|
||||||
assert(in_front_of_plane(plane, [0,0,-5]) == false);
|
assert(above_plane(plane, [0,0,-5]) == false);
|
||||||
}
|
}
|
||||||
*test_in_front_of_plane();
|
*test_above_plane();
|
||||||
|
|
||||||
|
|
||||||
module test_is_path() {
|
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(circle(r=50,$fn=1000),signed=true), -PI*50*50, eps=0.1));
|
||||||
assert(approx(polygon_area(rot([13,27,75],
|
assert(approx(polygon_area(rot([13,27,75],
|
||||||
p=path3d(circle(r=50,$fn=1000),fill=23)),
|
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], [10,0]) + 50) < EPSILON);
|
||||||
assert(abs(triangle_area([0,0], [0,10], [0,15])) < EPSILON);
|
assert(abs(triangle_area([0,0], [0,10], [0,15])) < EPSILON);
|
||||||
assert(abs(triangle_area([0,0], [10,0], [0,10]) - 50) < EPSILON);
|
assert(abs(triangle_area([0,0], [10,0], [0,10]) - 50) < EPSILON);
|
||||||
|
|
Loading…
Reference in a new issue