Last active
August 29, 2015 14:16
-
-
Save Feuermurmel/d453fc16992036b25f75 to your computer and use it in GitHub Desktop.
OpenSCAD minkowski() test cases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
minkowski() { | |
cube(); | |
intersection() { | |
cube(); | |
translate([2, 2, 2]) { | |
cube(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
minkowski() { | |
cube(); | |
intersection() { | |
cube(); | |
// Sharing a face with the other cube. | |
translate([1, 0, 0]) { | |
cube(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
minkowski() { | |
cube(); | |
intersection() { | |
cube(); | |
// Sharing an edge with the other cube. | |
translate([1, 1, 0]) { | |
cube(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
minkowski() { | |
cube(); | |
intersection() { | |
cube(); | |
// Sharing a corner with the other cube. | |
translate([1, 1, 1]) { | |
cube(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Demonstrates that A ⊕ (B ∪ C) = (A ⊕ B) ∪ (A ⊕ C) | |
// This works correctly in at least version 2015.02 | |
module empty() { } | |
module identity() { | |
translate([0, 0, 0]) { | |
minkowski() { | |
children(0); | |
union() { | |
children(1); | |
children(2); | |
} | |
} | |
} | |
translate([0, 5, 0]) { | |
union() { | |
minkowski() { | |
children(0); | |
children(1); | |
} | |
minkowski() { | |
children(0); | |
children(2); | |
} | |
} | |
} | |
} | |
translate([0, 0, 0]) { | |
identity() { | |
sphere($fn = 8); | |
cube(); | |
translate([1 / 2, 1 / 2, 1 / 2]) cube(); | |
} | |
} | |
translate([5, 0, 0]) { | |
identity() { | |
empty(); | |
cube(); | |
cube(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// t(A) ⊕ B = A ⊕ t(B) = t(A ⊕ B) | |
// This does not work correctly in at least version 2015.02 | |
module empty() { } | |
module identity() { | |
// t(A) ⊕ B | |
translate([0, 5, 0]) { | |
minkowski() { | |
translate([0, 0, 2]) { | |
children(0); | |
} | |
children(1); | |
} | |
} | |
// A ⊕ t(B) | |
translate([0, 10, 0]) { | |
minkowski() { | |
children(0); | |
translate([0, 0, 2]) { | |
children(1); | |
} | |
} | |
} | |
// t(A ⊕ B) | |
translate([0, 0, 0]) { | |
translate([0, 0, 2]) { | |
minkowski() { | |
children(0); | |
children(1); | |
} | |
} | |
} | |
} | |
module empty() { } | |
translate([0, 0, 0]) { | |
identity() { | |
cube(); | |
sphere($fn = 8); | |
} | |
} | |
translate([5, 0, 0]) { | |
identity() { | |
cube(); | |
empty(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example demonstrates how the intersection() can be fixed by wrapping each child in a module that does a union with an empty set. | |
// Takes the union with an empty set. Mathematically this does nothing. | |
module _fix_empty() { | |
children(0); | |
difference() { | |
cube(1, center = true); | |
cube(2, center = true); | |
} | |
} | |
// Version of intersection() that treats empty children in a mathematically correct way. | |
module intersection_fixed() { | |
intersection() { | |
_fix_empty() | |
children(0); | |
_fix_empty() | |
children(1); | |
} | |
} | |
module empty() { } | |
module identity() { | |
// Intersection with the original intersection() operator. | |
translate([0, 0, 0]) { | |
intersection() { | |
children(0); | |
children(1); | |
} | |
} | |
// Intersection with the intersection_fixed() operator. | |
translate([0, 2, 0]) { | |
intersection_fixed() { | |
children(0); | |
children(1); | |
} | |
} | |
} | |
// Expected: Empty. | |
// 2015.02: Empty. | |
translate([0, 0, 0]) { | |
identity() { | |
empty(); | |
empty(); | |
} | |
} | |
// Expected: Empty. | |
// 2015.02: A cube (intersection), empty (intersection_fixed). | |
translate([2, 0, 0]) { | |
identity() { | |
empty(); | |
cube(); | |
} | |
} | |
// Expected: A cube. | |
// 2015.02: A cube (intersection), empty (intersection_fixed). | |
translate([4, 0, 0]) { | |
identity() { | |
echo(); | |
cube(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
minkowski() { | |
cube(); | |
cube(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment