Skip to content

Instantly share code, notes, and snippets.

@bddap
Created April 10, 2018 21:10
Show Gist options
  • Save bddap/53a9e355b2bc62c7914aaaeec397620a to your computer and use it in GitHub Desktop.
Save bddap/53a9e355b2bc62c7914aaaeec397620a to your computer and use it in GitHub Desktop.
for printing
const len = 200; // length of longest resonator
const count = 8;
const irr = (Math.sqrt(5) + 1) / 2; // a very irrational number
const s = 1 / irr; // length ratio between largest and smallest resonator
function main() {
return Array(count).fill(0)
.map((_, i) => resonator(Math.pow(s, i / (count - 1))))
.reduce(combine);
}
function resonator(length) {
return cube({
center: [1, 1, 0]
}).scale([length, 0.04, 0.005])
.scale(len)
}
function combine(a, b) {
return union(
a.rotateZ(180 / count),
b
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment