File: difference-tests.scad

package info (click to toggle)
openscad 2021.01-10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 36,096 kB
  • sloc: cpp: 53,199; sh: 4,384; ansic: 4,382; python: 1,813; yacc: 853; javascript: 762; lex: 417; lisp: 163; xml: 127; makefile: 118
file content (48 lines) | stat: -rw-r--r-- 1,097 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Empty
difference();
// No children
difference() { }

// Basic
difference() {
  cube([10,10,10], center=true);
  cylinder(r=4, h=20, center=true);
}

// Two negative objects
translate([0,12,0]) difference() {
  cube([10,10,10], center=true);
  cylinder(r=4, h=11, center=true);
  rotate([0,90,0]) cylinder(r=4, h=11, center=true);
}

// Not intersecting
translate([12,12,0]) difference() {
  cube([10,10,10], center=true);
  translate([0,0,7.01]) cylinder(r=4, h=4, center=true);
}

// Barely intersecting
translate([24,0,0]) difference() {
  cube([10,10,10], center=true);
  translate([0,0,6.99]) cylinder(r=4, h=4, center=true);
}

// Subtracting something from nothing
translate([24,12,0]) difference() {
  cube([0,10,10], center=true);
  # cylinder(r=4, h=20, center=true);
}

// Non-geometry (echo) statement as first child should be ignored
translate([24,-12,0]) difference() {
  echo("difference-tests");
  cube([10,10,10], center=true);
  cylinder(r=4, h=20, center=true);
}

// Subtracting 2D from 3D
translate([12,0,0]) difference() {
  cube([10,10,10], center=true);
  circle(r=6);
}