mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-09-01 03:02:06 +02:00
remove polygon_shift, hide noncollinear_triple
modify glued circle to not produce duplicate points
This commit is contained in:
@@ -40,10 +40,9 @@ test_circle_2tangents();
|
||||
test_circle_3points();
|
||||
test_circle_point_tangents();
|
||||
|
||||
test_noncollinear_triple();
|
||||
test__noncollinear_triple();
|
||||
test_polygon_area();
|
||||
test_is_polygon_convex();
|
||||
test_polygon_shift();
|
||||
test_reindex_polygon();
|
||||
test_align_polygon();
|
||||
test_centroid();
|
||||
@@ -787,15 +786,6 @@ module test_is_polygon_convex() {
|
||||
*test_is_polygon_convex();
|
||||
|
||||
|
||||
module test_polygon_shift() {
|
||||
path = [[1,1],[-1,1],[-1,-1],[1,-1]];
|
||||
assert(polygon_shift(path,1) == [[-1,1],[-1,-1],[1,-1],[1,1]]);
|
||||
assert(polygon_shift(path,2) == [[-1,-1],[1,-1],[1,1],[-1,1]]);
|
||||
}
|
||||
*test_polygon_shift();
|
||||
|
||||
|
||||
|
||||
module test_reindex_polygon() {
|
||||
pent = subdivide_path([for(i=[0:4])[sin(72*i),cos(72*i)]],5);
|
||||
circ = circle($fn=5,r=2.2);
|
||||
@@ -827,13 +817,13 @@ module test_align_polygon() {
|
||||
*test_align_polygon();
|
||||
|
||||
|
||||
module test_noncollinear_triple() {
|
||||
assert(noncollinear_triple([[1,1],[2,2],[3,3],[4,4],[4,5],[5,6]]) == [0,5,3]);
|
||||
assert(noncollinear_triple([[1,1],[2,2],[8,3],[4,4],[4,5],[5,6]]) == [0,2,5]);
|
||||
module test__noncollinear_triple() {
|
||||
assert(_noncollinear_triple([[1,1],[2,2],[3,3],[4,4],[4,5],[5,6]]) == [0,5,3]);
|
||||
assert(_noncollinear_triple([[1,1],[2,2],[8,3],[4,4],[4,5],[5,6]]) == [0,2,5]);
|
||||
u = unit([5,3]);
|
||||
assert_equal(noncollinear_triple([for(i = [2,3,4,5,7,12,15]) i * u], error=false),[]);
|
||||
assert_equal(_noncollinear_triple([for(i = [2,3,4,5,7,12,15]) i * u], error=false),[]);
|
||||
}
|
||||
*test_noncollinear_triple();
|
||||
*test__noncollinear_triple();
|
||||
|
||||
|
||||
module test_centroid() {
|
||||
|
@@ -133,6 +133,9 @@ module test_list_rotate() {
|
||||
assert(list_rotate([1,2,3,4,5],5) == [1,2,3,4,5]);
|
||||
assert(list_rotate([1,2,3,4,5],6) == [2,3,4,5,1]);
|
||||
assert(list_rotate([],3) == []);
|
||||
path = [[1,1],[-1,1],[-1,-1],[1,-1]];
|
||||
assert(list_rotate(path,1) == [[-1,1],[-1,-1],[1,-1],[1,1]]);
|
||||
assert(list_rotate(path,2) == [[-1,-1],[1,-1],[1,1],[-1,1]]);
|
||||
}
|
||||
test_list_rotate();
|
||||
|
||||
|
@@ -100,10 +100,11 @@ test_teardrop2d();
|
||||
|
||||
module test_glued_circles() {
|
||||
$fn=24;
|
||||
assert_approx(glued_circles(r=15, spread=40, tangent=30), [[35,0],[34.4888873943,-3.88228567654],[32.9903810568,-7.5],[30.6066017178,-10.6066017178],[27.5,-12.9903810568],[23.8822856765,-14.4888873943],[20,-15],[16.1177143235,-14.4888873943],[12.5,-12.9903810568],[12.5,-12.9903810568],[6.47047612756,-10.4928704942],[0,-9.64101615138],[-6.47047612756,-10.4928704942],[-12.5,-12.9903810568],[-12.5,-12.9903810568],[-16.1177143235,-14.4888873943],[-20,-15],[-23.8822856765,-14.4888873943],[-27.5,-12.9903810568],[-30.6066017178,-10.6066017178],[-32.9903810568,-7.5],[-34.4888873943,-3.88228567654],[-35,0],[-34.4888873943,3.88228567654],[-32.9903810568,7.5],[-30.6066017178,10.6066017178],[-27.5,12.9903810568],[-23.8822856765,14.4888873943],[-20,15],[-16.1177143235,14.4888873943],[-12.5,12.9903810568],[-6.47047612756,10.4928704942],[0,9.64101615138],[6.47047612756,10.4928704942],[12.5,12.9903810568],[12.5,12.9903810568],[16.1177143235,14.4888873943],[20,15],[23.8822856765,14.4888873943],[27.5,12.9903810568],[30.6066017178,10.6066017178],[32.9903810568,7.5],[34.4888873943,3.88228567654]]);
|
||||
assert_approx(glued_circles(d=30, spread=40, tangent=30), [[35,0],[34.4888873943,-3.88228567654],[32.9903810568,-7.5],[30.6066017178,-10.6066017178],[27.5,-12.9903810568],[23.8822856765,-14.4888873943],[20,-15],[16.1177143235,-14.4888873943],[12.5,-12.9903810568],[12.5,-12.9903810568],[6.47047612756,-10.4928704942],[0,-9.64101615138],[-6.47047612756,-10.4928704942],[-12.5,-12.9903810568],[-12.5,-12.9903810568],[-16.1177143235,-14.4888873943],[-20,-15],[-23.8822856765,-14.4888873943],[-27.5,-12.9903810568],[-30.6066017178,-10.6066017178],[-32.9903810568,-7.5],[-34.4888873943,-3.88228567654],[-35,0],[-34.4888873943,3.88228567654],[-32.9903810568,7.5],[-30.6066017178,10.6066017178],[-27.5,12.9903810568],[-23.8822856765,14.4888873943],[-20,15],[-16.1177143235,14.4888873943],[-12.5,12.9903810568],[-6.47047612756,10.4928704942],[0,9.64101615138],[6.47047612756,10.4928704942],[12.5,12.9903810568],[12.5,12.9903810568],[16.1177143235,14.4888873943],[20,15],[23.8822856765,14.4888873943],[27.5,12.9903810568],[30.6066017178,10.6066017178],[32.9903810568,7.5],[34.4888873943,3.88228567654]]);
|
||||
assert_approx(glued_circles(d=30, spread=30, tangent=45), [[30,0],[29.4888873943,-3.88228567654],[27.9903810568,-7.5],[25.6066017178,-10.6066017178],[22.5,-12.9903810568],[18.8822856765,-14.4888873943],[15,-15],[11.1177143235,-14.4888873943],[7.5,-12.9903810568],[4.3933982822,-10.6066017178],[4.3933982822,-10.6066017178],[3.1066017178,-9.61920798589],[1.60809538023,-8.99850633757],[0,-8.7867965644],[-1.60809538023,-8.99850633757],[-3.1066017178,-9.61920798589],[-4.3933982822,-10.6066017178],[-4.3933982822,-10.6066017178],[-7.5,-12.9903810568],[-11.1177143235,-14.4888873943],[-15,-15],[-18.8822856765,-14.4888873943],[-22.5,-12.9903810568],[-25.6066017178,-10.6066017178],[-27.9903810568,-7.5],[-29.4888873943,-3.88228567654],[-30,0],[-29.4888873943,3.88228567654],[-27.9903810568,7.5],[-25.6066017178,10.6066017178],[-22.5,12.9903810568],[-18.8822856765,14.4888873943],[-15,15],[-11.1177143235,14.4888873943],[-7.5,12.9903810568],[-4.3933982822,10.6066017178],[-3.1066017178,9.61920798589],[-1.60809538023,8.99850633757],[0,8.7867965644],[1.60809538023,8.99850633757],[3.1066017178,9.61920798589],[4.3933982822,10.6066017178],[4.3933982822,10.6066017178],[7.5,12.9903810568],[11.1177143235,14.4888873943],[15,15],[18.8822856765,14.4888873943],[22.5,12.9903810568],[25.6066017178,10.6066017178],[27.9903810568,7.5],[29.4888873943,3.88228567654]]);
|
||||
assert_approx(glued_circles(d=30, spread=30, tangent=-30), [[30,0],[29.4888873943,-3.88228567654],[27.9903810568,-7.5],[25.6066017178,-10.6066017178],[22.5,-12.9903810568],[22.5,-12.9903810568],[11.6468570296,-17.4859000695],[0,-19.0192378865],[-11.6468570296,-17.4859000695],[-22.5,-12.9903810568],[-22.5,-12.9903810568],[-25.6066017178,-10.6066017178],[-27.9903810568,-7.5],[-29.4888873943,-3.88228567654],[-30,0],[-29.4888873943,3.88228567654],[-27.9903810568,7.5],[-25.6066017178,10.6066017178],[-22.5,12.9903810568],[-11.6468570296,17.4859000695],[0,19.0192378865],[11.6468570296,17.4859000695],[22.5,12.9903810568],[22.5,12.9903810568],[25.6066017178,10.6066017178],[27.9903810568,7.5],[29.4888873943,3.88228567654]]);
|
||||
assert_approx(glued_circles(r=15, spread=40, tangent=30), deduplicate([[35,0],[34.4888873943,-3.88228567654],[32.9903810568,-7.5],[30.6066017178,-10.6066017178],[27.5,-12.9903810568],[23.8822856765,-14.4888873943],[20,-15],[16.1177143235,-14.4888873943],[12.5,-12.9903810568],[12.5,-12.9903810568],[6.47047612756,-10.4928704942],[0,-9.64101615138],[-6.47047612756,-10.4928704942],[-12.5,-12.9903810568],[-12.5,-12.9903810568],[-16.1177143235,-14.4888873943],[-20,-15],[-23.8822856765,-14.4888873943],[-27.5,-12.9903810568],[-30.6066017178,-10.6066017178],[-32.9903810568,-7.5],[-34.4888873943,-3.88228567654],[-35,0],[-34.4888873943,3.88228567654],[-32.9903810568,7.5],[-30.6066017178,10.6066017178],[-27.5,12.9903810568],[-23.8822856765,14.4888873943],[-20,15],[-16.1177143235,14.4888873943],[-12.5,12.9903810568],[-6.47047612756,10.4928704942],[0,9.64101615138],[6.47047612756,10.4928704942],[12.5,12.9903810568],[12.5,12.9903810568],[16.1177143235,14.4888873943],[20,15],[23.8822856765,14.4888873943],[27.5,12.9903810568],[30.6066017178,10.6066017178],[32.9903810568,7.5],[34.4888873943,3.88228567654]]));
|
||||
assert_approx(glued_circles(d=30, spread=40, tangent=30),deduplicate( [[35,0],[34.4888873943,-3.88228567654],[32.9903810568,-7.5],[30.6066017178,-10.6066017178],[27.5,-12.9903810568],[23.8822856765,-14.4888873943],[20,-15],[16.1177143235,-14.4888873943],[12.5,-12.9903810568],[12.5,-12.9903810568],[6.47047612756,-10.4928704942],[0,-9.64101615138],[-6.47047612756,-10.4928704942],[-12.5,-12.9903810568],[-12.5,-12.9903810568],[-16.1177143235,-14.4888873943],[-20,-15],[-23.8822856765,-14.4888873943],[-27.5,-12.9903810568],[-30.6066017178,-10.6066017178],[-32.9903810568,-7.5],[-34.4888873943,-3.88228567654],[-35,0],[-34.4888873943,3.88228567654],[-32.9903810568,7.5],[-30.6066017178,10.6066017178],[-27.5,12.9903810568],[-23.8822856765,14.4888873943],[-20,15],[-16.1177143235,14.4888873943],[-12.5,12.9903810568],[-6.47047612756,10.4928704942],[0,9.64101615138],[6.47047612756,10.4928704942],[12.5,12.9903810568],[12.5,12.9903810568],[16.1177143235,14.4888873943],[20,15],[23.8822856765,14.4888873943],[27.5,12.9903810568],[30.6066017178,10.6066017178],[32.9903810568,7.5],[34.4888873943,3.88228567654]]));
|
||||
assert_approx(glued_circles(d=30, spread=30, tangent=45),deduplicate( [[30,0],[29.4888873943,-3.88228567654],[27.9903810568,-7.5],[25.6066017178,-10.6066017178],[22.5,-12.9903810568],[18.8822856765,-14.4888873943],[15,-15],[11.1177143235,-14.4888873943],[7.5,-12.9903810568],[4.3933982822,-10.6066017178],[4.3933982822,-10.6066017178],[3.1066017178,-9.61920798589],[1.60809538023,-8.99850633757],[0,-8.7867965644],[-1.60809538023,-8.99850633757],[-3.1066017178,-9.61920798589],[-4.3933982822,-10.6066017178],[-4.3933982822,-10.6066017178],[-7.5,-12.9903810568],[-11.1177143235,-14.4888873943],[-15,-15],[-18.8822856765,-14.4888873943],[-22.5,-12.9903810568],[-25.6066017178,-10.6066017178],[-27.9903810568,-7.5],[-29.4888873943,-3.88228567654],[-30,0],[-29.4888873943,3.88228567654],[-27.9903810568,7.5],[-25.6066017178,10.6066017178],[-22.5,12.9903810568],[-18.8822856765,14.4888873943],[-15,15],[-11.1177143235,14.4888873943],[-7.5,12.9903810568],[-4.3933982822,10.6066017178],[-3.1066017178,9.61920798589],[-1.60809538023,8.99850633757],[0,8.7867965644],[1.60809538023,8.99850633757],[3.1066017178,9.61920798589],[4.3933982822,10.6066017178],[4.3933982822,10.6066017178],[7.5,12.9903810568],[11.1177143235,14.4888873943],[15,15],[18.8822856765,14.4888873943],[22.5,12.9903810568],[25.6066017178,10.6066017178],[27.9903810568,7.5],[29.4888873943,3.88228567654]]));
|
||||
assert_approx(glued_circles(d=30, spread=30, tangent=-30), deduplicate([[30,0],[29.4888873943,-3.88228567654],[27.9903810568,-7.5],[25.6066017178,-10.6066017178],[22.5,-12.9903810568],[22.5,-12.9903810568],[11.6468570296,-17.4859000695],[0,-19.0192378865],[-11.6468570296,-17.4859000695],[-22.5,-12.9903810568],[-22.5,-12.9903810568],[-25.6066017178,-10.6066017178],[-27.9903810568,-7.5],[-29.4888873943,-3.88228567654],[-30,0],[-29.4888873943,3.88228567654],[-27.9903810568,7.5],[-25.6066017178,10.6066017178],[-22.5,12.9903810568],[-11.6468570296,17.4859000695],[0,19.0192378865],[11.6468570296,17.4859000695],[22.5,12.9903810568],[22.5,12.9903810568],[25.6066017178,10.6066017178],[27.9903810568,7.5],[29.4888873943,3.88228567654]]));
|
||||
assert_approx(glued_circles(d=30, spread=50, tangent=0),[[40, 0], [39.4888873943, -3.88228567654], [37.9903810568, -7.5], [35.6066017178, -10.6066017178], [32.5, -12.9903810568], [28.8822856765, -14.4888873943], [25, -15], [-25, -15], [-28.8822856765, -14.4888873943], [-32.5, -12.9903810568], [-35.6066017178, -10.6066017178], [-37.9903810568, -7.5], [-39.4888873943, -3.88228567654], [-40, 0], [-39.4888873943, 3.88228567654], [-37.9903810568, 7.5], [-35.6066017178, 10.6066017178], [-32.5, 12.9903810568], [-28.8822856765, 14.4888873943], [-25, 15], [25, 15], [28.8822856765, 14.4888873943], [32.5, 12.9903810568], [35.6066017178, 10.6066017178], [37.9903810568, 7.5], [39.4888873943, 3.88228567654]]);
|
||||
}
|
||||
test_glued_circles();
|
||||
|
||||
|
Reference in New Issue
Block a user