{ "nodes": [ { "datums": [ { "expr": "0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0", "name": "y", "type": "float", "uid": 1 }, { "expr": "0", "name": "z", "type": "float", "uid": 2 }, { "expr": "2", "name": "width", "type": "float", "uid": 3 }, { "expr": "2", "name": "height", "type": "float", "uid": 4 }, { "expr": "\u0012fab.types.Shape('m+f0/*-Xf0f2+*f0-Zf0*f1-f2Z+f0/*-Yf0f2+*f0-Zf0*f1-f2Z_am__f1aa-f-1X-Xf1a-f-1Y-Yf1a-f0Z-Zf2',float('-1.000000'),float('-1.000000'),float('0.000000'),float('1.000000'),float('1.000000'),float('2.000000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ -331, -267 ], "name": "p0", "script": [ "# Neil Gershenfeld 1/24/15 ", "# Matt Keeter 5/31/15", "", "import math", "import fab", "", "title('Pyramid (center)')", "", "input('x', float)", "input('y', float)", "input('z', float)", "input('width', float)", "input('height', float)", "", "output('shape', fab.shapes.pyramid(x - width/2, x + width/2,", " y - width/2, y + width/2,", " z, z + height))", "", "# UI", "def drag_w(this, x, y, z):", " dx = x - this.x", " dy = y - this.y", " this.width = math.sqrt(2) * math.sqrt(dx**2 +dy**2)", "", "sb.ui.wireframe([(x, y, z+height), (x, y, z), (x + width/2, y + width/2, z)])", "sb.ui.point(x, y, z)", "sb.ui.point(x + width/2, y + width/2, z, drag=drag_w, relative=False)", "sb.ui.point(x, y, z + height, drag=(None, None, height))", "", "" ], "uid": 0 }, { "datums": [ { "expr": "-1", "name": "xmin", "type": "float", "uid": 0 }, { "expr": "2", "name": "xmax", "type": "float", "uid": 1 }, { "expr": "-1", "name": "ymin", "type": "float", "uid": 2 }, { "expr": "2", "name": "ymax", "type": "float", "uid": 3 }, { "expr": "-1", "name": "zmin", "type": "float", "uid": 4 }, { "expr": "2", "name": "zmax", "type": "float", "uid": 5 }, { "expr": "60", "name": "x_period", "type": "float", "uid": 6 }, { "expr": "60", "name": "y_period", "type": "float", "uid": 7 }, { "expr": "60", "name": "z_period", "type": "float", "uid": 8 }, { "expr": "0.2", "name": "thickness", "type": "float", "uid": 9 }, { "expr": "\u0012fab.types.Shape('a= abs( sin(X/0.10471975511965977) * sin(Y/0.10471975511965977) * sin(Z/0.10471975511965977) + sin(X/0.10471975511965977) * cos(Y/0.10471975511965977) * cos(Z/0.10471975511965977) + cos(X/0.10471975511965977) * sin(X/0.10471975511965977) * cos(Z/0.10471975511965977) + cos(X/0.10471975511965977) * cos(Y/0.10471975511965977) * sin(Z/0.10471975511965977)) - 0.2;am__f1aa-f-1X-Xf2a-f-1Y-Yf2a-f-1Z-Zf2',float('-1.000000'),float('-1.000000'),float('-1.000000'),float('2.000000'),float('2.000000'),float('2.000000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 10 } ], "inspector": [ -328, -40 ], "name": "s0", "script": [ "import fab", "import math", "", "#http://en.wikipedia.org/wiki/Schwarz_minimal_surface", "title('Schwarz Diamond')", "", "input('xmin', float)", "input('xmax', float)", "input('ymin', float)", "input('ymax', float)", "input('zmin', float)", "input('zmax', float)", "", "input('x_period', float)", "input('y_period', float)", "input('z_period', float)", "input('thickness', float)", "", "x_factor = 2 * math.pi / x_period", "y_factor = 2 * math.pi / y_period", "z_factor = 2 * math.pi / z_period", "", "fn = \"= abs( sin(X/%(x_factor)s) * sin(Y/%(y_factor)s) * sin(Z/%(z_factor)s) + sin(X/%(x_factor)s) * cos(Y/%(y_factor)s) * cos(Z/%(z_factor)s) + cos(X/%(x_factor)s) * sin(X/%(x_factor)s) * cos(Z/%(z_factor)s) + cos(X/%(x_factor)s) * cos(Y/%(y_factor)s) * sin(Z/%(z_factor)s)) - %(thickness)s;\" % locals()", "", "output('shape', fab.shapes.function_prefix_xyz(fn, xmin, xmax,", " ymin, ymax,", " zmin, zmax))", "" ], "uid": 1 }, { "datums": [ { "expr": "\u0011[__0.__5]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__1.__10]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('am+f0/*-Xf0f2+*f0-Zf0*f1-f2Z+f0/*-Yf0f2+*f0-Zf0*f1-f2Z_am__f1aa-f-1X-Xf1a-f-1Y-Yf1a-f0Z-Zf2a= abs( sin(X/0.10471975511965977) * sin(Y/0.10471975511965977) * sin(Z/0.10471975511965977) + sin(X/0.10471975511965977) * cos(Y/0.10471975511965977) * cos(Z/0.10471975511965977) + cos(X/0.10471975511965977) * sin(X/0.10471975511965977) * cos(Z/0.10471975511965977) + cos(X/0.10471975511965977) * cos(Y/0.10471975511965977) * sin(Z/0.10471975511965977)) - 0.2;am__f1aa-f-1X-Xf2a-f-1Y-Yf2a-f-1Z-Zf2',float('-1.000000'),float('-1.000000'),float('0.000000'),float('1.000000'),float('1.000000'),float('2.000000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 2, -112 ], "name": "i0", "script": [ "import fab.types", "", "title('Intersection')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & b)", "" ], "uid": 2 } ], "protocol": 6, "type": "sb" }