mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-28 12:49:54 +02:00
Merge branch 'master' into pr/483
This commit is contained in:
@@ -27,6 +27,20 @@ module test_select() {
|
||||
}
|
||||
test_select();
|
||||
|
||||
|
||||
module test_slice() {
|
||||
l = [3,4,5,6,7,8,9];
|
||||
assert(slice(l, 5, 6) == [8,9]);
|
||||
assert(slice(l, 5, 8) == [8,9]);
|
||||
assert(slice(l, 5, 2) == []);
|
||||
assert(slice(l, -3, -1) == [7,8,9]);
|
||||
assert(slice(l, 3, 3) == [6]);
|
||||
assert(slice(l, 4) == [7,8,9]);
|
||||
assert(slice(l, -2) == [8,9]);
|
||||
}
|
||||
test_slice();
|
||||
|
||||
|
||||
module test_last() {
|
||||
list = [1,2,3,4];
|
||||
assert(last(list)==4);
|
||||
@@ -110,19 +124,36 @@ module test_repeat() {
|
||||
test_repeat();
|
||||
|
||||
|
||||
module test_list_range() {
|
||||
assert(list_range(4) == [0,1,2,3]);
|
||||
assert(list_range(n=4, step=2) == [0,2,4,6]);
|
||||
assert(list_range(n=4, s=3, step=3) == [3,6,9,12]);
|
||||
assert(list_range(e=3) == [0,1,2,3]);
|
||||
assert(list_range(e=6, step=2) == [0,2,4,6]);
|
||||
assert(list_range(s=3, e=5) == [3,4,5]);
|
||||
assert(list_range(s=3, e=8, step=2) == [3,5,7]);
|
||||
assert(list_range(s=4, e=8, step=2) == [4,6,8]);
|
||||
assert(list_range(e=4, n=3) == [0,2,4]);
|
||||
assert(list_range(n=4, s=[3,4], step=[2,3]) == [[3,4], [5,7], [7,10], [9,13]]);
|
||||
module test_range() {
|
||||
assert(range(4) == [0,1,2,3]);
|
||||
assert(range(n=4, step=2) == [0,2,4,6]);
|
||||
assert(range(n=4, s=3, step=3) == [3,6,9,12]);
|
||||
assert(range(e=3) == [0,1,2,3]);
|
||||
assert(range(e=6, step=2) == [0,2,4,6]);
|
||||
assert(range(s=3, e=5) == [3,4,5]);
|
||||
assert(range(s=3, e=8, step=2) == [3,5,7]);
|
||||
assert(range(s=4, e=8, step=2) == [4,6,8]);
|
||||
assert(range(e=4, n=3) == [0,2,4]);
|
||||
assert(range(n=4, s=[3,4], step=[2,3]) == [[3,4], [5,7], [7,10], [9,13]]);
|
||||
}
|
||||
test_list_range();
|
||||
test_range();
|
||||
|
||||
|
||||
module test_rangex() {
|
||||
assert_equal(rangex(4), [0,1,2,3]);
|
||||
assert_approx(rangex(5,e=1), [0, 0.2, 0.4, 0.6, 0.8]);
|
||||
assert_equal(rangex(n=4, step=2), [0,2,4,6]);
|
||||
assert_approx(rangex(n=4, step=0.25), [0,0.25,0.5,0.75]);
|
||||
assert_equal(rangex(n=4, s=3, step=3), [3,6,9,12]);
|
||||
assert_equal(rangex(e=3), [0,1,2]);
|
||||
assert_equal(rangex(e=6, step=2), [0,2,4]);
|
||||
assert_equal(rangex(s=3, e=5), [3,4]);
|
||||
assert_equal(rangex(s=3, e=8, step=2), [3,5,7]);
|
||||
assert_equal(rangex(s=4, e=8, step=2), [4,6]);
|
||||
assert_equal(rangex(e=6, n=3), [0,2,4]);
|
||||
assert_equal(rangex(n=4, s=[3,4], step=[2,3]), [[3,4], [5,7], [7,10], [9,13]]);
|
||||
}
|
||||
test_rangex();
|
||||
|
||||
|
||||
module test_reverse() {
|
||||
@@ -282,7 +313,7 @@ test_enumerate();
|
||||
|
||||
|
||||
module test_shuffle() {
|
||||
nums1 = [for (i=list_range(100)) i];
|
||||
nums1 = [for (i=range(100)) i];
|
||||
nums2 = shuffle(nums1,33);
|
||||
nums3 = shuffle(nums2,99);
|
||||
assert(sort(nums2)==nums1);
|
||||
|
@@ -481,7 +481,7 @@ module test_circle_3points() {
|
||||
radii = rands(10,100,count,seed_value=390);
|
||||
angles = rands(0,360,count,seed_value=699);
|
||||
// 2D tests.
|
||||
for(i = list_range(count)) {
|
||||
for(i = range(count)) {
|
||||
cp = select(coords,i,i+1);
|
||||
r = radii[i];
|
||||
angs = sort(select(angles,i,i+2));
|
||||
@@ -506,7 +506,7 @@ module test_circle_3points() {
|
||||
assert(approx(res[2], UP));
|
||||
}
|
||||
}
|
||||
for(i = list_range(count)) {
|
||||
for(i = range(count)) {
|
||||
cp = select(coords,i,i+1);
|
||||
r = radii[i];
|
||||
angs = sort(select(angles,i,i+2));
|
||||
@@ -532,7 +532,7 @@ module test_circle_3points() {
|
||||
}
|
||||
}
|
||||
// 3D tests.
|
||||
for(i = list_range(count)) {
|
||||
for(i = range(count)) {
|
||||
cp = select(coords,i,i+2);
|
||||
r = radii[i];
|
||||
nrm = unit(select(coords,i+10,i+12));
|
||||
@@ -559,7 +559,7 @@ module test_circle_3points() {
|
||||
assert(approx(res[2], n));
|
||||
}
|
||||
}
|
||||
for(i = list_range(count)) {
|
||||
for(i = range(count)) {
|
||||
cp = select(coords,i,i+2);
|
||||
r = radii[i];
|
||||
nrm = unit(select(coords,i+10,i+12));
|
||||
@@ -987,8 +987,8 @@ module test_pointlist_bounds() {
|
||||
|
||||
|
||||
module test_closest_point() {
|
||||
ptlist = [for (i=list_range(100)) rands(-100,100,2,seed_value=8463)];
|
||||
testpts = [for (i=list_range(100)) rands(-100,100,2,seed_value=6834)];
|
||||
ptlist = [for (i=range(100)) rands(-100,100,2,seed_value=8463)];
|
||||
testpts = [for (i=range(100)) rands(-100,100,2,seed_value=6834)];
|
||||
for (pt = testpts) {
|
||||
pidx = closest_point(pt,ptlist);
|
||||
dists = [for (p=ptlist) norm(pt-p)];
|
||||
@@ -1000,8 +1000,8 @@ module test_closest_point() {
|
||||
|
||||
|
||||
module test_furthest_point() {
|
||||
ptlist = [for (i=list_range(100)) rands(-100,100,2,seed_value=8463)];
|
||||
testpts = [for (i=list_range(100)) rands(-100,100,2,seed_value=6834)];
|
||||
ptlist = [for (i=range(100)) rands(-100,100,2,seed_value=8463)];
|
||||
testpts = [for (i=range(100)) rands(-100,100,2,seed_value=6834)];
|
||||
for (pt = testpts) {
|
||||
pidx = furthest_point(pt,ptlist);
|
||||
dists = [for (p=ptlist) norm(pt-p)];
|
||||
|
@@ -299,15 +299,6 @@ module test_modang() {
|
||||
test_modang();
|
||||
|
||||
|
||||
module test_modrange() {
|
||||
assert_equal(modrange(-5,5,3), [1,2]);
|
||||
assert_equal(modrange(-1,4,3), [2,0,1]);
|
||||
assert_equal(modrange(1,8,10,step=2), [1,3,5,7]);
|
||||
assert_equal(modrange(5,12,10,step=2), [5,7,9,1]);
|
||||
}
|
||||
test_modrange();
|
||||
|
||||
|
||||
module test_sqr() {
|
||||
assert_equal(sqr(-3), 9);
|
||||
assert_equal(sqr(0), 0);
|
||||
@@ -738,11 +729,14 @@ module test_any() {
|
||||
assert_equal(any([0,false,undef]), false);
|
||||
assert_equal(any([1,false,undef]), true);
|
||||
assert_equal(any([1,5,true]), true);
|
||||
assert_equal(any([[0,0], [0,0]]), false);
|
||||
assert_equal(any([[0,0], [0,0]]), true);
|
||||
assert_equal(any([[0,0], [1,0]]), true);
|
||||
assert_equal(any([[false,false],[[false,[false],[[[true]]]],false],[false,false]]), true);
|
||||
assert_equal(any([[false,false],[[false,[false],[[[false]]]],false],[false,false]]), false);
|
||||
assert_equal(any([[false,false],[[false,[false],[[[false]]]],false],[false,false]]), true);
|
||||
assert_equal(any([]), false);
|
||||
assert_equal(any([1,3,5,7,9], function (a) a%2==0),false);
|
||||
assert_equal(any([1,3,6,7,9], function (a) a%2==0),true);
|
||||
assert_equal(any([1,3,5,7,9], function (a) a%2!=0),true);
|
||||
}
|
||||
test_any();
|
||||
|
||||
@@ -751,12 +745,15 @@ module test_all() {
|
||||
assert_equal(all([0,false,undef]), false);
|
||||
assert_equal(all([1,false,undef]), false);
|
||||
assert_equal(all([1,5,true]), true);
|
||||
assert_equal(all([[0,0], [0,0]]), false);
|
||||
assert_equal(all([[0,0], [1,0]]), false);
|
||||
assert_equal(all([[0,0], [0,0]]), true);
|
||||
assert_equal(all([[0,0], [1,0]]), true);
|
||||
assert_equal(all([[1,1], [1,1]]), true);
|
||||
assert_equal(all([[true,true],[[true,[true],[[[true]]]],true],[true,true]]), true);
|
||||
assert_equal(all([[true,true],[[true,[true],[[[false]]]],true],[true,true]]), false);
|
||||
assert_equal(all([[true,true],[[true,[true],[[[true]]]],true],[true,true]]), true);
|
||||
assert_equal(all([[true,true],[[true,[true],[[[false]]]],true],[true,true]]), true);
|
||||
assert_equal(all([]), true);
|
||||
assert_equal(all([1,3,5,7,9], function (a) a%2==0),false);
|
||||
assert_equal(all([1,3,6,8,9], function (a) a%2==0),false);
|
||||
assert_equal(all([1,3,5,7,9], function (a) a%2!=0),true);
|
||||
}
|
||||
test_all();
|
||||
|
||||
@@ -770,6 +767,9 @@ module test_count_true() {
|
||||
assert_equal(count_true([[0,0], [1,0]]), 2);
|
||||
assert_equal(count_true([[1,1], [1,1]]), 2);
|
||||
assert_equal(count_true([1,1,1,1,1], nmax=3), 3);
|
||||
assert_equal(count_true([1,3,5,7,9], function (a) a%2==0),0);
|
||||
assert_equal(count_true([1,3,6,8,9], function (a) a%2==0),2);
|
||||
assert_equal(count_true([1,3,5,7,9], function (a) a%2!=0),5);
|
||||
}
|
||||
test_count_true();
|
||||
|
||||
@@ -789,6 +789,7 @@ module test_factorial() {
|
||||
}
|
||||
test_factorial();
|
||||
|
||||
|
||||
module test_binomial() {
|
||||
assert_equal(binomial(1), [1,1]);
|
||||
assert_equal(binomial(2), [1,2,1]);
|
||||
@@ -797,6 +798,7 @@ module test_binomial() {
|
||||
}
|
||||
test_binomial();
|
||||
|
||||
|
||||
module test_binomial_coefficient() {
|
||||
assert_equal(binomial_coefficient(2,1), 2);
|
||||
assert_equal(binomial_coefficient(3,2), 3);
|
||||
@@ -815,8 +817,8 @@ module test_gcd() {
|
||||
assert_equal(gcd(39, 101),1);
|
||||
assert_equal(gcd(15,-25), 5);
|
||||
assert_equal(gcd(-15,25), 5);
|
||||
assert_equal(gcd(5,0),5);
|
||||
assert_equal(gcd(0,5),5);
|
||||
assert_equal(gcd(5,0), 5);
|
||||
assert_equal(gcd(0,5), 5);
|
||||
}
|
||||
test_gcd();
|
||||
|
||||
@@ -830,6 +832,15 @@ module test_lcm() {
|
||||
test_lcm();
|
||||
|
||||
|
||||
|
||||
module test_complex(){
|
||||
assert_equal( complex(ident(4)), c_ident(4));
|
||||
assert_equal( complex(3), [3,0]);
|
||||
assert_equal( complex([1,2]), [[1,0],[2,0]]);
|
||||
assert_equal( complex([[1,2],[3,4]]), [[ [1,0],[2,0] ], [ [3,0],[4,0]]]);
|
||||
}
|
||||
test_complex();
|
||||
|
||||
module test_c_mul() {
|
||||
assert_equal(c_mul([4,5],[9,-4]), [56,29]);
|
||||
assert_equal(c_mul([-7,2],[24,3]), [-174, 27]);
|
||||
@@ -1122,7 +1133,7 @@ module test_real_roots(){
|
||||
// Wilkinson polynomial is a nasty test:
|
||||
assert_approx(
|
||||
sort(real_roots(poly_mult([[1,-1],[1,-2],[1,-3],[1,-4],[1,-5],[1,-6],[1,-7],[1,-8],[1,-9],[1,-10]]))),
|
||||
list_range(n=10,s=1));
|
||||
range(n=10,s=1));
|
||||
assert_equal(real_roots([3]), []);
|
||||
assert_equal(real_roots(poly_mult([[1,-2,5],[12,-24,24],[-2, -12, -20],[1,-10,50]])),[]);
|
||||
assert_equal(real_roots(poly_mult([[1,-2,5],[12,-24,24],[-2, -12, -20],[1,-10,50],[1,0,0]])),[0,0]);
|
||||
|
42
tests/test_rounding.scad
Normal file
42
tests/test_rounding.scad
Normal file
@@ -0,0 +1,42 @@
|
||||
include <../std.scad>
|
||||
include <../rounding.scad>
|
||||
|
||||
module test_round_corners() {
|
||||
|
||||
test1 = turtle(["move", 10, "move", 10, "left", 30, "move", 17, "left", 155, "move", 10, "right", 90, "move", 10,"left", 90, "move", 30]);
|
||||
test2 = turtle(["move", 20, "left", 30, "move", 17, "left", 155, "move", 10, "right", 90, "move", 10,"left", 90, "move", 30]);
|
||||
|
||||
assert_approx(round_corners(test2, cut=.5, $fn=8,closed=true),
|
||||
[[-0.606288551887,1.51404651037],[0.280235443937,0.414087063263],[1.63092692777,0],[16.2021229436,0],[19.8705904774,0.482962913145],[23.2890580113,1.89893852818],[34.1829092195,8.18850645576],[34.2505074296,8.28809878531],[34.2143124553,8.40289457772],[34.1018154298,8.44570309758],[25.9629982589,7.73364886061],[25.0818786883,8.01146479408],[24.6552785953,8.83095594797],[23.994133744,16.387876178],[23.5675336511,17.2073673319],[22.6864140805,17.4851832654],[-5.00680751277,15.0623403194],[-5.5709968443,14.7138107731],[-5.62744081644,14.0530562616]]);
|
||||
|
||||
assert_approx(round_corners(test2, cut=.5, $fn=8,closed=false),
|
||||
[[0,0],[16.2021229436,0],[19.8705904774,0.482962913145],[23.2890580113,1.89893852818],[34.1829092195,8.18850645576],[34.2505074296,8.28809878531],[34.2143124553,8.40289457772],[34.1018154298,8.44570309758],[25.9629982589,7.73364886061],[25.0818786883,8.01146479408],[24.6552785953,8.83095594797],[23.994133744,16.387876178],[23.5675336511,17.2073673319],[22.6864140805,17.4851832654],[-5.99691348681,14.975717271]]);
|
||||
|
||||
assert_approx(round_corners(test2, radius=[9,1.5,1.5,3], $fn=8,closed=false),[[0,0],[17.5884572681,0],[19.917828674,0.306667563398],[22.0884572681,1.20577136594],[28.8628496345,5.11696862225],[29.5970120924,6.19860893897],[29.2039100968,7.44536918473],[27.9821160204,7.91029877507],[26.2547769306,7.75917618664],[25.1598619019,8.1044015691],[24.6297512693,9.12273461966],[24.1503946842,14.6018054592],[23.090173419,16.6384715603],[20.9003433617,17.3289223252],[-5.99691348681,14.975717271]]);
|
||||
|
||||
assert_approx(round_corners(test2, radius=[0,9,1.5,1.5,3,0], $fn=8,closed=false),[[0,0],[17.5884572681,0],[19.917828674,0.306667563398],[22.0884572681,1.20577136594],[28.8628496345,5.11696862225],[29.5970120924,6.19860893897],[29.2039100968,7.44536918473],[27.9821160204,7.91029877507],[26.2547769306,7.75917618664],[25.1598619019,8.1044015691],[24.6297512693,9.12273461966],[24.1503946842,14.6018054592],[23.090173419,16.6384715603],[20.9003433617,17.3289223252],[-5.99691348681,14.975717271]]);
|
||||
|
||||
assert_approx(round_corners(test2, radius=[4,9,1.5,1.5,3,5], $fn=8,closed=true), [[-1.00632035384,2.51302092923],[0.46513599873,0.687303493898],[2.70701955022,0],[17.5884572681,0],[19.917828674,0.306667563398],[22.0884572681,1.20577136594],[28.8628496345,5.11696862225],[29.5970120924,6.19860893897],[29.2039100968,7.44536918473],[27.9821160204,7.91029877507],[26.2547769306,7.75917618664],[25.1598619019,8.1044015691],[24.6297512693,9.12273461966],[24.1503946842,14.6018054592],[23.090173419,16.6384715603],[20.9003433617,17.3289223252],[0.712818162855,15.5627427257],[-3.11056954856,13.2008342139],[-3.49307800348,8.72304539674]]);
|
||||
|
||||
assert_approx(round_corners(test1, radius=[4,0,9,1.5,1.5,3,5], $fn=8, closed=true),[[-1.00632035384,2.51302092923],[0.46513599873,0.687303493898],[2.70701955022,0],[10,0],[17.5884572681,0],[19.917828674,0.306667563398],[22.0884572681,1.20577136594],[28.8628496345,5.11696862225],[29.5970120924,6.19860893897],[29.2039100968,7.44536918473],[27.9821160204,7.91029877507],[26.2547769306,7.75917618664],[25.1598619019,8.1044015691],[24.6297512693,9.12273461966],[24.1503946842,14.6018054592],[23.090173419,16.6384715603],[20.9003433617,17.3289223252],[0.712818162855,15.5627427257],[-3.11056954856,13.2008342139],[-3.49307800348,8.72304539674]]);
|
||||
|
||||
assert_approx(round_corners(test1, joint=3, $fn=8, closed=true),[[-1.11523430308,2.78500492805],[0.515477620423,0.76169028093],[3,0],[7,0],[13,0],[17,0],[19.8977774789,0.381499642545],[22.5980762114,1.5],[32.124355653,7],[32.4498754498,7.47958777023],[32.2755782213,8.03238795439],[31.7338477701,8.23853277176],[27.7490689777,7.88990980077],[25.5592389204,8.58036056568],[24.4990176552,10.6170266668],[24.1503946842,14.6018054592],[23.090173419,16.6384715603],[20.9003433617,17.3289223252],[-3.00832939254,15.2371844993],[-4.71130594915,14.1851659419],[-4.88167918373,12.190712343]]);
|
||||
|
||||
assert_approx(round_corners(test1, joint=3, $fn=8, method="chamfer", closed=true), [[-1.11523430308,2.78500492805],[3,0],[7,0],[13,0],[17,0],[22.5980762114,1.5],[32.124355653,7],[31.7338477701,8.23853277176],[27.7490689777,7.88990980077],[24.4990176552,10.6170266668],[24.1503946842,14.6018054592],[20.9003433617,17.3289223252],[-3.00832939254,15.2371844993],[-4.88167918373,12.190712343]]);
|
||||
|
||||
assert_approx(round_corners(test1, joint=3, $fn=4, method="smooth", closed=true),[[-1.11523430308,2.78500492805],[-0.506080589514,1.46865494252],[0.353393568173,0.522188424009],[1.55153656203,0.0761524785012],[3,0],[7,0],[8.5,0],[10,0],[11.5,0],[13,0],[17,0],[18.4890098964,0.041015625],[19.9246392896,0.28125],[21.2880480021,0.791015625],[22.5980762114,1.5],[32.124355653,7],[33.2706335159,7.70183488048],[33.674933057,8.1697248947],[33.0753795745,8.32110126636],[31.7338477701,8.23853277176],[27.7490689777,7.88990980077],[26.3293465324,7.8480447775],[25.2718192958,8.2378271955],[24.7043208711,9.21160321051],[24.4990176552,10.6170266668],[24.1503946842,14.6018054592],[23.9450914683,16.0072289155],[23.3775930436,16.9810049305],[22.320065807,17.3707873485],[20.9003433617,17.3289223252],[-3.00832939254,15.2371844993],[-4.39040765537,15.0374479012],[-5.22744753731,14.5025539523],[-5.32708255097,13.514211823],[-4.88167918373,12.190712343]]);
|
||||
|
||||
assert_approx(round_corners(test1, joint=3, $fn=4, method="smooth", k=.1, closed=true), [[-1.11523430308,2.78500492805],[-0.374134800869,0.998685360916],[0.164916998481,0.243687931204],[1.06619720521,0.0239336361004],[3,0],[7,0],[8.95,0],[10,0],[11.05,0],[13,0],[17,0],[18.9465459674,0.012890625],[19.9648316685,0.13125],[20.9058726414,0.537890625],[22.5980762114,1.5],[32.124355653,7],[33.7650948284,7.95986239101],[34.2335990876,8.34587161753],[33.6284170693,8.39334886112],[31.7338477701,8.23853277176],[27.7490689777,7.88990980077],[25.829925477,7.74788623096],[24.9991076092,7.91282206324],[24.6924075141,8.70237713407],[24.4990176552,10.6170266668],[24.1503946842,14.6018054592],[23.9570048253,16.5164549919],[23.6503047302,17.3060100627],[22.8194868624,17.470945895],[20.9003433617,17.3289223252],[-3.00832939254,15.2371844993],[-4.91564186446,15.0455441488],[-5.63782937704,14.7549077223],[-5.57131429138,13.9792788941],[-4.88167918373,12.190712343]]);
|
||||
|
||||
assert_approx(round_corners(test1, joint=[3,0,3,5,2,2,4], $fn=4, method="smooth", k=[.8,0,.7,.5,0,.4,1], closed=true),[[-1.11523430308,2.78500492805],[-0.605039930997,1.82113212873],[0.494750995442,0.731063793612],[1.91554107964,0.115316610302],[3,0],[10,0],[17,0],[18.2602418609,0.055078125],[19.9045431002,0.35625],[21.4791356824,0.917578125],[22.5980762114,1.5],[30.3923048454,6],[32.3027679503,7.1697248008],[32.9766005188,7.94954149117],[31.9773447146,8.20183544393],[29.7414583739,8.06422128626],[26.7528742796,7.80275405802],[25.3902084366,7.69137858706],[24.8741147528,7.76386137763],[24.713114411,8.25952793415],[24.5861733979,9.62083196871],[24.0632389414,15.5980001573],[23.9283556903,16.6198201409],[23.5934897955,17.2383006602],[22.9262565325,17.4606811745],[21.8965380598,17.4160780679],[-2.01213469444,15.324340242],[-2.97951536307,15.0445310318],[-4.28698915458,13.9242432294],[-4.69675267167,12.2519315552],[-4.50993441604,11.262377367]]);
|
||||
|
||||
assert_approx(round_corners(test2, cut=.6, $fn=4, method="smooth", k=[.8,.7,.5,0,.4,1], closed=true), [[-0.758025389489,1.89296943206],[-0.411245984888,1.23782454268],[0.336282532724,0.496904475915],[1.30199436026,0.0783807655462],[2.03910170463,0],[15.1195326672,0],[17.1697224117,0.0896023299387],[19.8447085729,0.579555495773],[22.4062911263,1.49273668813],[24.2266086926,2.44023366641],[33.3031485364,7.68057638855],[33.9293399672,8.06397643682],[34.1502016939,8.3195765203],[33.8226761739,8.40227076906],[33.0898209499,8.35716505304],[31.5228787369,8.220075373],[26.897837498,7.84205448929],[25.1461574492,8.08806923839],[24.5997041686,9.77041731835],[24.1688520829,14.390836426],[24.116478533,14.9894688406],[23.9403981733,16.3233811597],[23.5032548901,17.1307628876],[22.6322299704,17.4210646163],[21.2880067431,17.3628384763],[-4.80585474409,15.0799214086],[-5.0950068559,14.9962858485],[-5.48581351579,14.6614294736],[-5.6082926909,14.161572005],[-5.55245232227,13.8657921816]]);
|
||||
|
||||
assert_approx(round_corners([[0,0],[10,0],[10,10]], cut=1, method="chamfer",closed=false), [[0,0],[8.58578643763,0],[10,1.41421356237],[10,10]]);
|
||||
|
||||
}
|
||||
test_round_corners();
|
||||
|
||||
|
||||
|
||||
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
@@ -40,7 +40,7 @@ test_turtle();
|
||||
|
||||
module test_arc() {
|
||||
assert_approx(arc(N=8, d=100, angle=135, cp=[10,10]), [[60,10],[57.1941665154,26.5139530978],[49.0915741234,41.1744900929],[36.6016038258,52.3362099614],[21.1260466978,58.7463956091],[4.40177619483,59.6856104947],[-11.6941869559,55.0484433951],[-25.3553390593,45.3553390593]]);
|
||||
assert_approx(arc(N=8, d=100, angle=135, cp=[10,10],endpoint=false), [[60,10],[57.1941665154,26.5139530978],[49.0915741234,41.1744900929],[36.6016038258,52.3362099614],[21.1260466978,58.7463956091],[4.40177619483,59.6856104947],[-11.6941869559,55.0484433951]]);
|
||||
assert_approx(arc(N=8, d=100, angle=135, cp=[10,10],endpoint=false), [[60,10],[57.8470167866,24.5142338627],[51.5734806151,37.778511651],[41.7196642082,48.6505226681],[29.1341716183,56.1939766256],[14.9008570165,59.7592363336],[0.245483899194,59.0392640202],[-13.5698368413,54.0960632174]]);
|
||||
assert_approx(arc(N=8, d=100, angle=[45,225], cp=[10,10]), [[45.3553390593,45.3553390593],[26.5139530978,57.1941665154],[4.40177619483,59.6856104947],[-16.6016038258,52.3362099614],[-32.3362099614,36.6016038258],[-39.6856104947,15.5982238052],[-37.1941665154,-6.51395309776],[-25.3553390593,-25.3553390593]]);
|
||||
assert_approx(arc(N=8, d=100, start=45, angle=135, cp=[10,10]), [[45.3553390593,45.3553390593],[31.6941869559,55.0484433951],[15.5982238052,59.6856104947],[-1.12604669782,58.7463956091],[-16.6016038258,52.3362099614],[-29.0915741234,41.1744900929],[-37.1941665154,26.5139530978],[-40,10]]);
|
||||
assert_approx(arc(N=8, d=100, start=45, angle=-90, cp=[10,10]), [[45.3553390593,45.3553390593],[52.3362099614,36.6016038258],[57.1941665154,26.5139530978],[59.6856104947,15.5982238052],[59.6856104947,4.40177619483],[57.1941665154,-6.51395309776],[52.3362099614,-16.6016038258],[45.3553390593,-25.3553390593]]);
|
||||
|
Reference in New Issue
Block a user