Skip to content
Snippets Groups Projects
Commit 0b01c1e3 authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

Menger sponge working

parent 16a6ff46
Branches
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ var name = 'Menger sponge' ...@@ -26,7 +26,7 @@ var name = 'Menger sponge'
// //
var init = function() { var init = function() {
mod.size.value = '1' mod.size.value = '1'
mod.depth.value = '3' mod.depth.value = '4'
} }
// //
// inputs // inputs
...@@ -51,7 +51,9 @@ var outputs = { ...@@ -51,7 +51,9 @@ var outputs = {
var fn = `Math.min(${fn},Math.min(Y-0,${size}-Y))` var fn = `Math.min(${fn},Math.min(Y-0,${size}-Y))`
var fn = `Math.min(${fn},Math.min(Z-0,${size}-Z))` var fn = `Math.min(${fn},Math.min(Z-0,${size}-Z))`
for (var d = 0; d < depth; ++d) { for (var d = 0; d < depth; ++d) {
var fn = `Math.min(${fn},-Math.min(Math.min((Math.pow(3,${d})*X/${size})%1-1/3,2/3-(Math.pow(3,${d})*X/${size})%1),Math.min(Math.min((Math.pow(3,${d})*Y/${size})%1-1/3,2/3-(Math.pow(3,${d})*Y/${size})%1),Math.min((Math.pow(3,${d})*Z/${size})%1-1/3,2/3-(Math.pow(3,${d})*Z/${size})%1))))` var fn = `Math.min(${fn},-Math.min(Math.min((Math.pow(3,${d})*X/${size})%1-1/3,2/3-(Math.pow(3,${d})*X/${size})%1),Math.min((Math.pow(3,${d})*Y/${size})%1-1/3,2/3-(Math.pow(3,${d})*Y/${size})%1)))`
var fn = `Math.min(${fn},-Math.min(Math.min((Math.pow(3,${d})*X/${size})%1-1/3,2/3-(Math.pow(3,${d})*X/${size})%1),Math.min((Math.pow(3,${d})*Z/${size})%1-1/3,2/3-(Math.pow(3,${d})*Z/${size})%1)))`
var fn = `Math.min(${fn},-Math.min(Math.min((Math.pow(3,${d})*Y/${size})%1-1/3,2/3-(Math.pow(3,${d})*Y/${size})%1),Math.min((Math.pow(3,${d})*Z/${size})%1-1/3,2/3-(Math.pow(3,${d})*Z/${size})%1)))`
} }
var variables = ['X','Y','Z'] var variables = ['X','Y','Z']
var limits = [[0,size],[0,size],[0,size]] var limits = [[0,size],[0,size],[0,size]]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment