2020-07-22 00:05:21 +00:00
|
|
|
include <../std.scad>
|
2020-06-25 05:33:41 +00:00
|
|
|
|
|
|
|
|
2021-09-17 01:50:12 +00:00
|
|
|
module test_square() {
|
|
|
|
assert(square(100, center=true) == [[50,-50],[-50,-50],[-50,50],[50,50]]);
|
|
|
|
assert(square(100, center=false) == [[100,0],[0,0],[0,100],[100,100]]);
|
|
|
|
assert(square(100, anchor=FWD+LEFT) == [[100,0],[0,0],[0,100],[100,100]]);
|
|
|
|
assert(square(100, anchor=BACK+RIGHT) == [[0,-100],[-100,-100],[-100,0],[0,0]]);
|
|
|
|
}
|
|
|
|
test_square();
|
|
|
|
|
|
|
|
|
|
|
|
module test_circle() {
|
|
|
|
for (pt = circle(d=200)) {
|
|
|
|
assert(approx(norm(pt),100));
|
|
|
|
}
|
|
|
|
for (pt = circle(r=100)) {
|
|
|
|
assert(approx(norm(pt),100));
|
|
|
|
}
|
|
|
|
assert(is_polygon_clockwise(circle(d=200)));
|
|
|
|
assert(is_polygon_clockwise(circle(r=100)));
|
|
|
|
assert(len(circle(d=100,$fn=6)) == 6);
|
|
|
|
assert(len(circle(d=100,$fn=36)) == 36);
|
|
|
|
}
|
|
|
|
test_circle();
|
|
|
|
|
2020-06-25 05:33:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
module test_rect() {
|
|
|
|
assert_equal(rect(100,anchor=CENTER), [[50,-50],[-50,-50],[-50,50],[50,50]]);
|
2021-11-12 11:18:14 +00:00
|
|
|
assert_equal(rect(100), [[50,-50],[-50,-50],[-50,50],[50,50]]);
|
2020-06-25 05:33:41 +00:00
|
|
|
assert_equal(rect([100,80],anchor=CENTER), [[50,-40],[-50,-40],[-50,40],[50,40]]);
|
2021-11-12 11:18:14 +00:00
|
|
|
assert_equal(rect([100,80]), [[50,-40],[-50,-40],[-50,40],[50,40]]);
|
2020-06-25 05:33:41 +00:00
|
|
|
assert_equal(rect([100,80],anchor=FRONT+LEFT), [[100,0],[0,0],[0,80],[100,80]]);
|
|
|
|
assert_equal(rect([100,80],anchor=BACK+RIGHT), [[0,-80],[-100,-80],[-100,0],[0,0]]);
|
|
|
|
assert_approx(rect([100,80],rounding=10,anchor=CENTER,$fn=12), [[50,-30],[48.6602540378,-35],[45,-38.6602540378],[40,-40],[-40,-40],[-45,-38.6602540378],[-48.6602540378,-35],[-50,-30],[-50,30],[-48.6602540378,35],[-45,38.6602540378],[-40,40],[40,40],[45,38.6602540378],[48.6602540378,35],[50,30]]);
|
|
|
|
}
|
|
|
|
test_rect();
|
|
|
|
|
|
|
|
|
|
|
|
module test_trapezoid() {
|
|
|
|
assert_equal(trapezoid(w1=100,w2=80,h=60,anchor=CENTER), [[50,-30],[-50,-30],[-40,30],[40,30]]);
|
|
|
|
}
|
|
|
|
test_trapezoid();
|
|
|
|
|
|
|
|
|
2021-11-14 00:45:58 +00:00
|
|
|
module test_ellipse() {
|
|
|
|
assert_approx(ellipse(d=100,$fn=24), [[50,0],[48.2962913145,-12.9409522551],[43.3012701892,-25],[35.3553390593,-35.3553390593],[25,-43.3012701892],[12.9409522551,-48.2962913145],[0,-50],[-12.9409522551,-48.2962913145],[-25,-43.3012701892],[-35.3553390593,-35.3553390593],[-43.3012701892,-25],[-48.2962913145,-12.9409522551],[-50,0],[-48.2962913145,12.9409522551],[-43.3012701892,25],[-35.3553390593,35.3553390593],[-25,43.3012701892],[-12.9409522551,48.2962913145],[0,50],[12.9409522551,48.2962913145],[25,43.3012701892],[35.3553390593,35.3553390593],[43.3012701892,25],[48.2962913145,12.9409522551]]);
|
|
|
|
assert_approx(ellipse(d=[100,80],$fn=24), [[50,0],[48.2962913145,-10.3527618041],[43.3012701892,-20],[35.3553390593,-28.2842712475],[25,-34.6410161514],[12.9409522551,-38.6370330516],[0,-40],[-12.9409522551,-38.6370330516],[-25,-34.6410161514],[-35.3553390593,-28.2842712475],[-43.3012701892,-20],[-48.2962913145,-10.3527618041],[-50,0],[-48.2962913145,10.3527618041],[-43.3012701892,20],[-35.3553390593,28.2842712475],[-25,34.6410161514],[-12.9409522551,38.6370330516],[0,40],[12.9409522551,38.6370330516],[25,34.6410161514],[35.3553390593,28.2842712475],[43.3012701892,20],[48.2962913145,10.3527618041]]);
|
2020-06-25 05:33:41 +00:00
|
|
|
}
|
2021-11-14 00:45:58 +00:00
|
|
|
test_ellipse();
|
2020-06-25 05:33:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
module test_star() {
|
|
|
|
assert_approx(star(n=5,d=100,step=2), [[50,0],[15.4508497187,-11.2256994145],[15.4508497187,-47.5528258148],[-5.90169943749,-18.1635632001],[-40.4508497187,-29.3892626146],[-19.0983005625,0],[-40.4508497187,29.3892626146],[-5.90169943749,18.1635632001],[15.4508497187,47.5528258148],[15.4508497187,11.2256994145]]);
|
|
|
|
assert_approx(star(n=6,d=100,step=2), [[50,0],[25,-14.4337567297],[25,-43.3012701892],[0,-28.8675134595],[-25,-43.3012701892],[-25,-14.4337567297],[-50,0],[-25,14.4337567297],[-25,43.3012701892],[0,28.8675134595],[25,43.3012701892],[25,14.4337567297]]);
|
|
|
|
assert_approx(star(n=7,d=100,step=3), [[50,0],[16.0776033027,-7.74256568183],[31.1744900929,-39.0915741234],[3.97084009243,-17.3973871675],[-11.1260466978,-48.7463956091],[-11.1260466978,-13.951621274],[-45.0484433951,-21.6941869559],[-17.8447933946,0],[-45.0484433951,21.6941869559],[-11.1260466978,13.951621274],[-11.1260466978,48.7463956091],[3.97084009243,17.3973871675],[31.1744900929,39.0915741234],[16.0776033027,7.74256568183]]);
|
|
|
|
}
|
|
|
|
test_star();
|
|
|
|
|
|
|
|
|
|
|
|
module test_regular_ngon() {
|
|
|
|
assert_approx(regular_ngon(n=7,d=100), [[50,0],[31.1744900929,-39.0915741234],[-11.1260466978,-48.7463956091],[-45.0484433951,-21.6941869559],[-45.0484433951,21.6941869559],[-11.1260466978,48.7463956091],[31.1744900929,39.0915741234]]);
|
|
|
|
assert_approx(regular_ngon(n=9,d=100), [[50,0],[38.3022221559,-32.1393804843],[8.68240888335,-49.2403876506],[-25,-43.3012701892],[-46.9846310393,-17.1010071663],[-46.9846310393,17.1010071663],[-25,43.3012701892],[8.68240888335,49.2403876506],[38.3022221559,32.1393804843]]);
|
|
|
|
assert_approx(regular_ngon(n=5,d=100,rounding=10,$fn=24), [[47.4207962323,2.07911690818],[47.4207962323,-2.07911690818],[45.7294901688,-5.87785252292],[19.72135955,-41.6749732918],[16.6311896062,-44.4573748068],[12.6764742389,-45.7423397226],[8.5410196625,-45.3076859319],[-33.5410196625,-31.6344024975],[-37.1421557823,-29.5552855893],[-39.5863042952,-26.1912037653],[-40.4508497187,-22.1238373346],[-40.4508497187,22.1238373346],[-39.5863042952,26.1912037653],[-37.1421557823,29.5552855893],[-33.5410196625,31.6344024975],[8.5410196625,45.3076859319],[12.6764742389,45.7423397226],[16.6311896062,44.4573748068],[19.72135955,41.6749732918],[45.7294901688,5.87785252292]]);
|
|
|
|
}
|
|
|
|
test_regular_ngon();
|
|
|
|
|
|
|
|
|
|
|
|
module test_pentagon() {
|
|
|
|
assert_approx(pentagon(d=100), [[50,0],[15.4508497187,-47.5528258148],[-40.4508497187,-29.3892626146],[-40.4508497187,29.3892626146],[15.4508497187,47.5528258148]]);
|
|
|
|
assert_approx(pentagon(d=100,rounding=10,$fn=24), [[47.4207962323,2.07911690818],[47.4207962323,-2.07911690818],[45.7294901688,-5.87785252292],[19.72135955,-41.6749732918],[16.6311896062,-44.4573748068],[12.6764742389,-45.7423397226],[8.5410196625,-45.3076859319],[-33.5410196625,-31.6344024975],[-37.1421557823,-29.5552855893],[-39.5863042952,-26.1912037653],[-40.4508497187,-22.1238373346],[-40.4508497187,22.1238373346],[-39.5863042952,26.1912037653],[-37.1421557823,29.5552855893],[-33.5410196625,31.6344024975],[8.5410196625,45.3076859319],[12.6764742389,45.7423397226],[16.6311896062,44.4573748068],[19.72135955,41.6749732918],[45.7294901688,5.87785252292]]);
|
|
|
|
}
|
|
|
|
test_pentagon();
|
|
|
|
|
|
|
|
|
|
|
|
module test_hexagon() {
|
|
|
|
assert_approx(hexagon(d=100), [[50,0],[25,-43.3012701892],[-25,-43.3012701892],[-50,0],[-25,43.3012701892],[25,43.3012701892]]);
|
|
|
|
assert_approx(hexagon(d=100,rounding=10,$fn=24), [[48.3010721463,1.73648177667],[48.3010721463,-1.73648177667],[47.1132486541,-5],[27.8867513459,-38.3012701892],[25.654373405,-40.9617146204],[22.6466987414,-42.6981963971],[19.2264973081,-43.3012701892],[-19.2264973081,-43.3012701892],[-22.6466987414,-42.6981963971],[-25.654373405,-40.9617146204],[-27.8867513459,-38.3012701892],[-47.1132486541,-5],[-48.3010721463,-1.73648177667],[-48.3010721463,1.73648177667],[-47.1132486541,5],[-27.8867513459,38.3012701892],[-25.654373405,40.9617146204],[-22.6466987414,42.6981963971],[-19.2264973081,43.3012701892],[19.2264973081,43.3012701892],[22.6466987414,42.6981963971],[25.654373405,40.9617146204],[27.8867513459,38.3012701892],[47.1132486541,5]]);
|
|
|
|
}
|
|
|
|
test_hexagon();
|
|
|
|
|
|
|
|
|
|
|
|
module test_octagon() {
|
|
|
|
assert_approx(octagon(d=100), [[50,0],[35.3553390593,-35.3553390593],[0,-50],[-35.3553390593,-35.3553390593],[-50,0],[-35.3553390593,35.3553390593],[0,50],[35.3553390593,35.3553390593]]);
|
|
|
|
assert_approx(octagon(d=100,rounding=10,$fn=24), [[49.1760779971,0],[48.4148733222,-3.82683432365],[36.9404657371,-31.5285047357],[34.7727382239,-34.7727382239],[31.5285047357,-36.9404657371],[3.82683432365,-48.4148733222],[0,-49.1760779971],[-3.82683432365,-48.4148733222],[-31.5285047357,-36.9404657371],[-34.7727382239,-34.7727382239],[-36.9404657371,-31.5285047357],[-48.4148733222,-3.82683432365],[-49.1760779971,0],[-48.4148733222,3.82683432365],[-36.9404657371,31.5285047357],[-34.7727382239,34.7727382239],[-31.5285047357,36.9404657371],[-3.82683432365,48.4148733222],[0,49.1760779971],[3.82683432365,48.4148733222],[31.5285047357,36.9404657371],[34.7727382239,34.7727382239],[36.9404657371,31.5285047357],[48.4148733222,3.82683432365]]);
|
|
|
|
}
|
|
|
|
test_octagon();
|
|
|
|
|
|
|
|
|
|
|
|
module test_teardrop2d() {
|
2020-07-01 00:19:09 +00:00
|
|
|
$fn=24;
|
2022-10-26 03:45:20 +00:00
|
|
|
assert_approx(teardrop2d(r=50),[[0,70.7106781187],[35.3553390593,35.3553390593],[43.6811195323,24.3302239283],[48.671902718,11.4475274975],[49.9466487401,-2.30917293229],[47.4080323795,-15.8895709791],[41.2498737299,-28.2568207211],[31.9423402826,-38.4666985491],[20.1960502436,-45.7396934244],[6.90781774759,-49.5205215438],[-6.90781774759,-49.5205215438],[-20.1960502436,-45.7396934244],[-31.9423402826,-38.4666985491],[-41.2498737299,-28.2568207211],[-47.4080323795,-15.8895709791],[-49.9466487401,-2.30917293229],[-48.671902718,11.4475274975],[-43.6811195323,24.3302239283],[-35.3553390593,35.3553390593]]);
|
|
|
|
assert_approx(teardrop2d(d=100),[[0,70.7106781187],[35.3553390593,35.3553390593],[43.6811195323,24.3302239283],[48.671902718,11.4475274975],[49.9466487401,-2.30917293229],[47.4080323795,-15.8895709791],[41.2498737299,-28.2568207211],[31.9423402826,-38.4666985491],[20.1960502436,-45.7396934244],[6.90781774759,-49.5205215438],[-6.90781774759,-49.5205215438],[-20.1960502436,-45.7396934244],[-31.9423402826,-38.4666985491],[-41.2498737299,-28.2568207211],[-47.4080323795,-15.8895709791],[-49.9466487401,-2.30917293229],[-48.671902718,11.4475274975],[-43.6811195323,24.3302239283],[-35.3553390593,35.3553390593]]);
|
|
|
|
assert_approx(teardrop2d(r=50,cap_h=50),[[20.7106781187,50],[35.3553390593,35.3553390593],[43.6811195323,24.3302239283],[48.671902718,11.4475274975],[49.9466487401,-2.30917293229],[47.4080323795,-15.8895709791],[41.2498737299,-28.2568207211],[31.9423402826,-38.4666985491],[20.1960502436,-45.7396934244],[6.90781774759,-49.5205215438],[-6.90781774759,-49.5205215438],[-20.1960502436,-45.7396934244],[-31.9423402826,-38.4666985491],[-41.2498737299,-28.2568207211],[-47.4080323795,-15.8895709791],[-49.9466487401,-2.30917293229],[-48.671902718,11.4475274975],[-43.6811195323,24.3302239283],[-35.3553390593,35.3553390593],[-20.7106781187,50]]);
|
|
|
|
assert_approx(teardrop2d(r=50,cap_h=50,ang=30),[[28.8675134595,50],[43.3012701892,25],[48.5147863138,12.09609478],[49.969541351,-1.74497483513],[47.5528258148,-15.4508497187],[41.4518786278,-27.9596451735],[32.1393804843,-38.3022221559],[20.3368321538,-45.6772728821],[6.958655048,-49.5134034371],[-6.958655048,-49.5134034371],[-20.3368321538,-45.6772728821],[-32.1393804843,-38.3022221559],[-41.4518786278,-27.9596451735],[-47.5528258148,-15.4508497187],[-49.969541351,-1.74497483513],[-48.5147863138,12.09609478],[-43.3012701892,25],[-28.8675134595,50]]);
|
2020-06-25 05:33:41 +00:00
|
|
|
}
|
|
|
|
test_teardrop2d();
|
|
|
|
|
|
|
|
|
|
|
|
module test_glued_circles() {
|
2020-07-01 00:19:09 +00:00
|
|
|
$fn=24;
|
2021-11-11 23:50:26 +00:00
|
|
|
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]]);
|
2020-06-25 05:33:41 +00:00
|
|
|
}
|
|
|
|
test_glued_circles();
|
|
|
|
|
|
|
|
|
|
|
|
module test_supershape() {
|
2020-07-01 00:19:09 +00:00
|
|
|
$fn = 24;
|
|
|
|
assert_approx(supershape(step=0.5,m1=16,m2=16,n1=0.5,n2=0.5,n3=16,r=50), [[31.8072679929,0],[31.8254440703,-0.277736442783],[31.8800818691,-0.556468898942],[31.9715117231,-0.837203498428],[32.1002896772,-1.12096681644],[32.2672058831,-1.40881663388],[32.4732966814,-1.70185336507],[32.7198607165,-2.00123241238],[33.0084795316,-2.30817774075],[33.3410431535,-2.6239970035],[33.7197810671,-2.95009857994],[34.1472983973,-3.2880108612],[34.6266155102,-3.63940394304],[35.1612056414,-4.00611335337],[35.7550182057,-4.39016421046],[36.4124633674,-4.79379174563],[37.138314422,-5.21944970831],[37.9374570742,-5.66979094838],[38.8143785616,-6.14759362503],[39.7722470564,-6.65559159145],[40.8113899535,-7.19614916902],[41.9269541846,-7.77070164547],[43.1055530065,-8.37887071896],[44.3208250346,-9.01717376565],[45.5281335086,-9.67730351785],[46.6592118851,-10.344098238],[47.6184628391,-10.9935883798],[48.28369535,-11.5918896634],[48.5147863138,-12.09609478],[48.1730192886,-12.4583898795],[47.1505372707,-12.6339483844],[45.4034911139,-12.5915024719],[42.9767802608,-12.3233934346],[40.0076792879,-11.8508145072],[36.7032455714,-11.2213082803],[33.2989492854,-10.4991183806],[30.0149182764,-9.75243812881],[27.0253656239,-9.04256084558],[24.4481119546,-8.41816003875],[22.3518922366,-7.9152201722],[20.7749251664,-7.56145437968],[19.7499695415,-7.38421103185],[19.3382230386,-7.42324832601],[19.694017676,-7.75767986951],[21.2841774283,-8.59936587637],[29.3860838838,-12.1721144897],[21.1308561166,-8.96951626646],[19.4112814895,-8.44026540548],[18.9232178765,-8.42515941694],[19.1867630853,-8.74391169667],[20.0368461313,-9.3433347963],[21.4020804312,-10.2082687145],[23.2399637988,-11.3348877018],[25.5038753899,-12.7157632035],[28.119767384,-14.327737116],[30.9699106495,-16.1219150427],[33.8877770139,-18.0184506563],[36.6694926246,-19.9099100234],[39.1031278208,-21.6752176912],[41.0086532394,-23.201579673],[42.2740152165,-24.406914065],[42.8728805757,-25.2540566427],[42.8583650351,-25.7519037455],[42.3384321905,-25.945024615],[41.4449788762,-25.8976970902],[40.3074271381,-25.6786631194],[39.0361388798,-25.3503649976],[37.7156606466,-24.9634512129],[36.4049851418,-24.5554725336],[35.1415494465,-24.1521177904],[33.9464564616,-23.7695647099],[32.8294395437,-23.4170116495],[31.7929154287,-23.0989051482],[30.8349807857,-22.8166855306],[29.9514622525,-22.5700456868],[29.1372224177,-22.3577771159],[28.3869307184,-22.1783009509],[27.6954768621,-22.0299770253],[27.0581618444,-21.9112674292],[26.4707610325,-21.8208114794],[25.9295205637,-21.7574511416],[25.4311237807,-21.7202316307],[24.9726478461,-21.7083915808],[24.5515204017,-21.7213503826],[24.1654803459,-21.7586962359],[23.8125438851,-21.8201762946],[23.4909757462,-21.9056892714],[23.1992650151,-22.0152804732],[22.9361050064,-22.1491391425],[22.7003766384,-22.3075979943],[22.4911348888,-22.4911348888],[22.3075979943,-22.7003766384],[22.1491391425,-22.9361050064],[22.0152804732,-23.1992650151],[21.9056892714,-23.4909757462],[21.8201762946,-23.8125438851],[21.7586962359,-24.1654803459],[21.7213503826,-24.5515204017],[21.7083915808,-24.9726478461],[21.7202316307,-25.4311237807],[21.7574511416,-25.9295205637],[21.8208114794,-26.4707610325],[21.9112674292,-27.0581618444],[22.0299770253,-27.6954768621],[22.1783009509,-28.3869307184],[22.3577771159,-29.1372224177],[22.5700456868,-29.9514622525],[22.8166855306,-30.8349807857],[23.0989051482,-31.7929154287],[23.4170116495,-32.8294395437],[23.7695647099,-33.9464564616],[24.1521177904,-35.1415494465],[24.5554725336,-36.4049851418],[24.9634512129,-37.7156606466],[25.3503649976,-39.0361388798],[25.6786631194,-40.3074271381],[25.8976970902,-41.4449788762],[25.945024615,-42.3384321905],[25.7519037455,-42.8583650351],[25.2540566427,-42.8728805757],[24.406914065,-42.2740152165],[23.201579673,-41.0086532394],[21.6752176912,-39.1031278208],[19.9099100234,-36.6694926246],[18.0184506563,-33.8877770139],[16.1219150427,-30.9699106495],[14.327737116,-28.119767384],[12.7157632035,-25.5038753899],[11.3348877018,-23.2399637988],[10.2082687145,-21.4020804312],[9.3433347963,-20.
|
|
|
|
assert_approx(supershape(m1=7, n1=2, n2=8, n3=4), [[1,0],[1.00019517316,-0.00872857104113],[1.00078102433,-0.0174686977586],[1.0017585498,-0.0262319708163],[1.00312941419,-0.0350300510433],[1.00489595654,-0.0438747049874],[1.00706119869,-0.0527778410254],[1.00962885581,-0.0617515462009],[1.01260334878,-0.0708081239432],[1.01598981818,-0.0799601328075],[1.01979413959,-0.0892204263441],[1.0240229395,-0.0986021941772],[1.02868361163,-0.10811900433],[1.03378433254,-0.117784846781],[1.03933407606,-0.12761417816],[1.04534262515,-0.137621967435],[1.05182058018,-0.147823742296],[1.0587793619,-0.158235635844],[1.06623120726,-0.168874433019],[1.07418915584,-0.179757615985],[1.08266702407,-0.190903407467],[1.09167936393,-0.202330810682],[1.10124140209,-0.214059644174],[1.11136895468,-0.226110569338],[1.12207831186,-0.238505107894],[1.1333860853,-0.251265645826],[1.14530901022,-0.26441541947],[1.15786369227,-0.277978478424],[1.17106628758,-0.291979618679],[1.18493210244,-0.306444277958],[1.19947509676,-0.321398383517],[1.21470727308,-0.336868140672],[1.23063793043,-0.35287974809],[1.2472727598,-0.369459023352],[1.26461275593,-0.386630919653],[1.28265291846,-0.404418911741],[1.30138071516,-0.422844226653],[1.32077428165,-0.441924892758],[1.34080033604,-0.461674579605],[1.36141179612,-0.482101201868],[1.38254510094,-0.503205264274],[1.40411726123,-0.524977932173],[1.42602269563,-0.547398825996],[1.44812995451,-0.570433559133],[1.47027849121,-0.594031069729],[1.49227571289,-0.618120839079],[1.51389462641,-0.642610143307],[1.53487248259,-0.667381549418],[1.55491090311,-0.692290937163],[1.57367802873,-0.717166395447],[1.59081323057,-0.741808392109],[1.60593484806,-0.76599162963],[1.61865123028,-0.789468954531],[1.62857504526,-0.811977564899],[1.63534039155,-0.83324754808],[1.63862174143,-0.853012486907],[1.63815324577,-0.871021531282],[1.63374655172,-0.88705200202],[1.62530514368,-0.900921352515],[1.6128334029,-0.912497235111],[1.59643910952,-0.921704549628],[1.57632890991,-0.928528688623],[1.55279718806,-0.933014679643],[1.52620962151,-0.935262458929],[1.49698329573,-0.935418981821],[1.46556549563,-0.933668192529],[1.4324131807,-0.930219996144],[1.39797475806,-0.925299307277],[1.36267521949,-0.919136041237],[1.32690513459,-0.911956632875],[1.29101349317,-0.903977379849],[1.25530402436,-0.895399658682],[1.22003440231,-0.88640687891],[1.18541766257,-0.87716292795],[1.15162516709,-0.867811808863],[1.11879053251,-0.85847816949],[1.08701404382,-0.849268448251],[1.05636719081,-0.840272404763],[1.02689707061,-0.831564851513],[0.998630490424,-0.823207449243],[0.971577675677,-0.815250469321],[0.945735541708,-0.807734459729],[0.921090524428,-0.800691777214],[0.897620989299,-0.794147967228],[0.875299252405,-0.788122986837],[0.854093254551,-0.782632274663],[0.833967931608,-0.77768767758],[0.814886323466,-0.77329824687],[0.796810461115,-0.769470917947],[0.779702067617,-0.766211087893],[0.763523104482,-0.763523104482],[0.748236190758,-0.761410679404],[0.733804918133,-0.759877237135],[0.720194081714,-0.758926209655],[0.707369842875,-0.758561285914],[0.695299837765,-0.758786623746],[0.683953242625,-0.759607030817],[0.673300804976,-0.761028120197],[0.663314848035,-0.76305644522],[0.653969254213,-0.765699617546],[0.645239432346,-0.768966411581],[0.637102272286,-0.772866857811],[0.62953608962,-0.777412327008],[0.622520562564,-0.782615606762],[0.616036662471,-0.788490971254],[0.610066578882,-0.795054244721],[0.604593639556,-0.802322858557],[0.59960222555,-0.810315901451],[0.595077681001,-0.819054161405],[0.591006216921,-0.828560157837],[0.58737480797,-0.838858161213],[0.584171080778,-0.849974196821],[0.581383192055,-0.86193602829],[0.578999694296,-0.874773115235],[0.577009386474,-0.888516538024],[0.575401146653,-0.903198880958],[0.574163742953,-0.918854063171],[0.573285618773,-0.935517104201],[0.572754647627,-0.953223808466],[0.572557852412,-0.97201034972],[0.572681083409,-0.991912732999],[0.573108648924,-1.01296610763],[0.573822892216,-1.03520390063],[0.574803708461,-1.05865673543],[0.576027996016,-1.08335109689],[0.577469037497,-1.10930769991],[0.57
|
2020-06-25 05:33:41 +00:00
|
|
|
}
|
|
|
|
test_supershape();
|
|
|
|
|
|
|
|
|
2021-01-11 09:57:51 +00:00
|
|
|
module test_reuleaux_polygon() {
|
|
|
|
$fn=36;
|
2022-03-14 01:40:55 +00:00
|
|
|
assert_approx(reuleaux_polygon(n=3, r=50),[[50,0],[45.5443467787,-6.93313174371],[40.449833029,-13.4113329645],[34.7625954562,-19.375936069],[28.5341385645,-24.7729246878],[21.8208682239,-29.5534228563],[14.6835808504,-33.6741376427],[7.18691282348,-37.0977512159],[-0.601244870218,-39.7932588011],[-8.61036146861,-41.7362494642],[-16.7679051715,-42.909127181],[-25,-43.3012701892],[-28.7764416072,-35.9759954373],[-31.8394715604,-28.3249164997],[-34.161350586,-20.417322732],[-35.7210513879,-12.324826528],[-36.5044490743,-4.12071478641],[-36.5044490743,4.12071478641],[-35.7210513879,12.324826528],[-34.161350586,20.417322732],[-31.8394715604,28.3249164997],[-28.7764416072,35.9759954373],[-25,43.3012701892],[-16.7679051715,42.909127181],[-8.61036146861,41.7362494642],[-0.601244870218,39.7932588011],[7.18691282348,37.0977512159],[14.6835808504,33.6741376427],[21.8208682239,29.5534228563],[28.5341385645,24.7729246878],[34.7625954562,19.375936069],[40.449833029,13.4113329645],[45.5443467787,6.93313174371]]);
|
|
|
|
assert_approx(reuleaux_polygon(n=3, d=100),[[50,0],[45.5443467787,-6.93313174371],[40.449833029,-13.4113329645],[34.7625954562,-19.375936069],[28.5341385645,-24.7729246878],[21.8208682239,-29.5534228563],[14.6835808504,-33.6741376427],[7.18691282348,-37.0977512159],[-0.601244870218,-39.7932588011],[-8.61036146861,-41.7362494642],[-16.7679051715,-42.909127181],[-25,-43.3012701892],[-28.7764416072,-35.9759954373],[-31.8394715604,-28.3249164997],[-34.161350586,-20.417322732],[-35.7210513879,-12.324826528],[-36.5044490743,-4.12071478641],[-36.5044490743,4.12071478641],[-35.7210513879,12.324826528],[-34.161350586,20.417322732],[-31.8394715604,28.3249164997],[-28.7764416072,35.9759954373],[-25,43.3012701892],[-16.7679051715,42.909127181],[-8.61036146861,41.7362494642],[-0.601244870218,39.7932588011],[7.18691282348,37.0977512159],[14.6835808504,33.6741376427],[21.8208682239,29.5534228563],[28.5341385645,24.7729246878],[34.7625954562,19.375936069],[40.449833029,13.4113329645],[45.5443467787,6.93313174371]]);
|
|
|
|
assert_approx(reuleaux_polygon(n=5, d=100),[[50,0],[47.0014382812,-7.98963912753],[43.2987621605,-15.6783253167],[38.921783409,-23.0041537871],[33.9057428858,-29.9081412755],[28.2910268,-36.3347009341],[22.122841544,-42.2320898832],[15.4508497187,-47.5528258148],[6.92564483387,-47.1699584219],[-1.53092011402,-46.0244388665],[-9.85075783633,-44.1254901984],[-17.9668818917,-41.4884016357],[-25.8139460215,-38.134405465],[-33.3287702792,-34.0905060913],[-40.4508497187,-29.3892626146],[-42.7211543799,-21.1629984251],[-44.2449228251,-12.7663422159],[-45.0098865668,-4.26689892573],[-45.0098865668,4.26689892573],[-44.2449228251,12.7663422159],[-42.7211543799,21.1629984251],[-40.4508497187,29.3892626146],[-33.3287702792,34.0905060913],[-25.8139460215,38.134405465],[-17.9668818917,41.4884016357],[-9.85075783633,44.1254901984],[-1.53092011402,46.0244388665],[6.92564483387,47.1699584219],[15.4508497187,47.5528258148],[22.122841544,42.2320898832],[28.2910268,36.3347009341],[33.9057428858,29.9081412755],[38.921783409,23.0041537871],[43.2987621605,15.6783253167],[47.0014382812,7.98963912753]]);
|
2021-01-11 09:57:51 +00:00
|
|
|
}
|
|
|
|
test_reuleaux_polygon();
|
|
|
|
|
|
|
|
|
2020-06-25 05:33:41 +00:00
|
|
|
|
|
|
|
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|