Added shape_compare()

This commit is contained in:
Garth Minette 2020-07-21 16:54:59 -07:00
parent 4a37a5dc8e
commit 6798083a11
2 changed files with 37 additions and 1 deletions

View file

@ -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

View file

@ -8,7 +8,7 @@
//////////////////////////////////////////////////////////////////////
BOSL_VERSION = [2,0,397];
BOSL_VERSION = [2,0,398];
// Section: BOSL Library Version Functions