diff --git a/common.scad b/common.scad index 8d0655a..648f3c7 100644 --- a/common.scad +++ b/common.scad @@ -379,5 +379,41 @@ module assert_equal(got, expected, info) { } +// Module: shape_compare() +// Usage: +// shape_compare([eps]) {test_shape(); expected_shape();} +// Description: +// Compares two child shapes, returning empty geometry if they are very nearly the same shape and size. +// Returns the differential geometry if they are not nearly the same shape and size. +// Arguments: +// eps = The surface of the two shapes must be within this size of each other. Default: 1/1024 +module shape_compare(eps=1/1024) { + union() { + difference() { + children(0); + if (eps==0) { + children(1); + } else { + minkowski() { + children(1); + cube(eps, center=true); + } + } + } + difference() { + children(1); + if (eps==0) { + children(0); + } else { + minkowski() { + children(0); + cube(eps, center=true); + } + } + } + } +} + + // vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap diff --git a/version.scad b/version.scad index 406f9e4..7efaa86 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,397]; +BOSL_VERSION = [2,0,398]; // Section: BOSL Library Version Functions