mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-30 08:19:36 +00:00
Remove triangle_area (because polygon_area)
This commit is contained in:
parent
1920014f86
commit
566d9b4ece
2 changed files with 9 additions and 12 deletions
|
@ -1689,9 +1689,10 @@ function furthest_point(pt, points) =
|
||||||
// area = polygon_area(poly);
|
// area = polygon_area(poly);
|
||||||
// Topics: Geometry, Polygons, Area
|
// Topics: Geometry, Polygons, Area
|
||||||
// Description:
|
// Description:
|
||||||
// Given a 2D or 3D planar polygon, returns the area of that polygon.
|
// Given a 2D or 3D simple planar polygon, returns the area of that polygon.
|
||||||
// If the polygon is self-crossing, the results are undefined. For non-planar 3D polygon the result is `undef`.
|
// If the polygon is self-intersecting or non-planar, the result is `undef.`
|
||||||
// When `signed` is true, a signed area is returned; a positive area indicates a clockwise polygon.
|
// When `signed` is true and the polygon is 2d, a signed area is returned: a positive area indicates a counter-clockwise polygon.
|
||||||
|
// The area of 3d polygons is always nonnegative.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// poly = Polygon to compute the area of.
|
// poly = Polygon to compute the area of.
|
||||||
// signed = If true, a signed area is returned. Default: false.
|
// signed = If true, a signed area is returned. Default: false.
|
||||||
|
@ -1706,7 +1707,7 @@ function polygon_area(poly, signed=false) =
|
||||||
let(
|
let(
|
||||||
n = plane_normal(plane),
|
n = plane_normal(plane),
|
||||||
total =
|
total =
|
||||||
sum([ for(i=[1:1:len(poly)-2])
|
-sum([ for(i=[1:1:len(poly)-2])
|
||||||
cross(poly[i]-poly[0], poly[i+1]-poly[0])
|
cross(poly[i]-poly[0], poly[i+1]-poly[0])
|
||||||
]) * n/2
|
]) * n/2
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,7 +32,6 @@ test_tri_calc();
|
||||||
//test_hyp_adj_to_ang();
|
//test_hyp_adj_to_ang();
|
||||||
//test_hyp_opp_to_ang();
|
//test_hyp_opp_to_ang();
|
||||||
//test_adj_opp_to_ang();
|
//test_adj_opp_to_ang();
|
||||||
test_triangle_area();
|
|
||||||
test_plane3pt();
|
test_plane3pt();
|
||||||
test_plane3pt_indexed();
|
test_plane3pt_indexed();
|
||||||
test_plane_from_normal();
|
test_plane_from_normal();
|
||||||
|
@ -649,13 +648,6 @@ module test_hyp_opp_to_ang() nil(); // Covered in test_tri_functions()
|
||||||
module test_adj_opp_to_ang() nil(); // Covered in test_tri_functions()
|
module test_adj_opp_to_ang() nil(); // Covered in test_tri_functions()
|
||||||
|
|
||||||
|
|
||||||
module test_triangle_area() {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
*test_triangle_area();
|
|
||||||
|
|
||||||
|
|
||||||
module test_plane3pt() {
|
module test_plane3pt() {
|
||||||
assert_approx(plane3pt([0,0,20], [0,10,10], [0,0,0]), [1,0,0,0]);
|
assert_approx(plane3pt([0,0,20], [0,10,10], [0,0,0]), [1,0,0,0]);
|
||||||
|
@ -817,6 +809,10 @@ module test_polygon_area() {
|
||||||
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], [0,15])) < EPSILON);
|
||||||
|
assert(abs(triangle_area([0,0], [10,0], [0,10]) - 50) < EPSILON);
|
||||||
|
|
||||||
}
|
}
|
||||||
*test_polygon_area();
|
*test_polygon_area();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue