From c400843cb2aaf08ba549413bd0da3db848a15387 Mon Sep 17 00:00:00 2001 From: Garth Minette Date: Wed, 23 Sep 2020 19:38:22 -0700 Subject: [PATCH] Added regressions for vnf_centroid() and vnf_volume() --- tests/test_vnf.scad | 19 +++++++++++++++++++ version.scad | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/test_vnf.scad b/tests/test_vnf.scad index 753803c..6e1131a 100644 --- a/tests/test_vnf.scad +++ b/tests/test_vnf.scad @@ -65,6 +65,25 @@ module test_vnf_add_faces() { test_vnf_add_faces(); +module test_vnf_centroid() { + assert_approx(vnf_centroid(cube(100, center=false)), [50,50,50]); + assert_approx(vnf_centroid(cube(100, center=true)), [0,0,0]); + assert_approx(vnf_centroid(cube(100, anchor=ALLPOS)), [-50,-50,-50]); + assert_approx(vnf_centroid(cube(100, anchor=BOT)), [0,0,50]); + assert_approx(vnf_centroid(cube(100, anchor=TOP)), [0,0,-50]); + assert_approx(vnf_centroid(sphere(d=100, anchor=CENTER, $fn=36)), [0,0,0]); + assert_approx(vnf_centroid(sphere(d=100, anchor=BOT, $fn=36)), [0,0,50]); +} +test_vnf_centroid(); + + +module test_vnf_volume() { + assert_approx(vnf_volume(cube(100, center=false)), 1000000); + assert(approx(vnf_volume(sphere(d=100, anchor=BOT, $fn=144)), 4/3*PI*pow(50,3), eps=1e3)); +} +test_vnf_volume(); + + module test_vnf_merge() { vnf1 = vnf_add_face(pts=[[-1,-1,-1],[1,-1,-1],[0,1,-1]]); vnf2 = vnf_add_face(pts=[[1,1,1],[-1,1,1],[0,1,-1]]); diff --git a/version.scad b/version.scad index e03aa50..78f2ad2 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,426]; +BOSL_VERSION = [2,0,427]; // Section: BOSL Library Version Functions