{ "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": "4", "name": "width", "type": "float", "uid": 3 }, { "expr": "10", "name": "height", "type": "float", "uid": 4 }, { "expr": "\u0012fab.types.Shape('m+f0/*-Xf0f10+*f0-Zf0*f1-f10Z+f0/*-Yf0f10+*f0-Zf0*f1-f10Z_am__f1aa-f-2X-Xf2a-f-2Y-Yf2a-f0Z-Zf10',float('-2.000000'),float('-2.000000'),float('0.000000'),float('2.000000'),float('2.000000'),float('10.000000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ -282.45030669905282, -274.74711651635124 ], "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": 2 }, { "datums": [ { "expr": "0.0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0.0", "name": "_y", "type": "float", "uid": 1 }, { "expr": "0.0", "name": "z", "type": "float", "uid": 2 }, { "expr": "180", "name": "a", "type": "float", "uid": 3 }, { "expr": "\u0011[__2.__5]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf0m+*f-1X*f1.22465e-16ZY+*f-1.22465e-16X*f-1Zm-Xf-0-Yf0-Zf-0m+f0/*-Xf0f10+*f0-Zf0*f1-f10Z+f0/*-Yf0f10+*f0-Zf0*f1-f10Z_am__f1aa-f-2X-Xf2a-f-2Y-Yf2a-f0Z-Zf10',float('-2.000000'),float('-2.000000'),float('-10.000000'),float('2.000000'),float('2.000000'),float('0.000000'))", "name": "rotated", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 42.3675460048579, -285.01803675995325 ], "name": "r0", "script": [ "import fab", "import math", "", "title('Rotate (Y)')", "", "input('x', float)", "input('_y', float)", "input('z', float)", "input('a', float)", "", "input('shape', fab.types.Shape)", "output('rotated', fab.shapes.rotate_y(shape, a, x, z))", "", "# UI", "rad = math.radians(a)", "sb.ui.wireframe([(x + math.cos(rad), _y, z + math.sin(rad)),", " (x, _y, z),", " (x + 1, _y, z)], color=sb.color.teal)", "", "# Draw a semi-circular arc showing the rotation", "if int(a) % 360 != 0:", " sb.ui.wireframe([", " (x + math.cos(math.radians(a_)) * 0.3, _y,", " z + math.sin(math.radians(a_)) * 0.3)", " for a_ in range(int(a) % 360)], color=sb.color.teal)", "", "sb.ui.point(x, _y, z, color=sb.color.teal)", "", "def drag_pt(this, x, y, z):", " this.a = math.degrees(math.atan2(z - this.z, x - this.x))", "sb.ui.point(x + math.cos(rad), _y, z + math.sin(rad),", " color=sb.color.teal, drag=drag_pt, relative=False)", "", "" ], "uid": 3 }, { "datums": [ { "expr": "\u0011[__3.__5]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__0.__6]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('am-Xf0-Yf0-Zf0m+*f-1X*f1.22465e-16ZY+*f-1.22465e-16X*f-1Zm-Xf-0-Yf0-Zf-0m+f0/*-Xf0f10+*f0-Zf0*f1-f10Z+f0/*-Yf0f10+*f0-Zf0*f1-f10Z_am__f1aa-f-2X-Xf2a-f-2Y-Yf2a-f0Z-Zf10nam__f1aa-f-1X-Xf1a-f-3Y-Yf3a-f-12Z-Zf-8',float('-2.000000'),float('-2.000000'),float('-10.000000'),float('2.000000'),float('2.000000'),float('0.000000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 109.1285275882704, 139.94128831907611 ], "name": "d0", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 1 }, { "datums": [ { "expr": "\u0011[__1.__2]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "0", "name": "x", "type": "float", "uid": 1 }, { "expr": "0", "name": "y", "type": "float", "uid": 2 }, { "expr": "-2", "name": "z0", "type": "float", "uid": 3 }, { "expr": "2", "name": "z1", "type": "float", "uid": 4 }, { "expr": "0", "name": "theta0", "type": "float", "uid": 5 }, { "expr": "90", "name": "theta1", "type": "float", "uid": 6 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf-2mXY/Zf4m+*Xc+*f1.5708Z*f0-f1Z*Ys+*f1.5708Z*f0-f1Z+n*Xs+*f1.5708Z*f0-f1Z*Yc+*f1.5708Z*f0-f1Z_mXY/Zf0.25m-Xf-0-Yf-0-Zf2am-Xf0-Yf0-Zf0m+*f-1X*f1.22465e-16ZY+*f-1.22465e-16X*f-1Zm-Xf-0-Yf0-Zf-0m+f0/*-Xf0f10+*f0-Zf0*f1-f10Z+f0/*-Yf0f10+*f0-Zf0*f1-f10Z_am__f1aa-f-2X-Xf2a-f-2Y-Yf2a-f0Z-Zf10nam__f1aa-f-1X-Xf1a-f-3Y-Yf3a-f-12Z-Zf-8',float('-4.000000'),float('-4.000000'),float('-10.000000'),float('4.000000'),float('4.000000'),float('0.000000'))", "name": "twisted", "type": "_fabtypes.Shape", "uid": 7 } ], "inspector": [ 430.0947852008303, 7.7031901827014382 ], "name": "t0", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/13/15", "", "import fab", "", "title('Twist (Z)')", "", "input('shape', fab.types.Shape)", "input('x', float)", "input('y', float)", "input('z0', float)", "input('z1', float)", "input('theta0', float)", "input('theta1', float)", "", "output('twisted', fab.shapes.twist_xy_z(shape, x, y, z0, z1, theta0, theta1))", "", "" ], "uid": 4 }, { "datums": [ { "expr": "0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0", "name": "y", "type": "float", "uid": 1 }, { "expr": "-10", "name": "z", "type": "float", "uid": 2 }, { "expr": "2", "name": "width", "type": "float", "uid": 3 }, { "expr": "6", "name": "height", "type": "float", "uid": 4 }, { "expr": "4", "name": "depth", "type": "float", "uid": 5 }, { "expr": "\u0012fab.types.Shape('am__f1aa-f-1X-Xf1a-f-3Y-Yf3a-f-12Z-Zf-8',float('-1.000000'),float('-3.000000'),float('-12.000000'),float('1.000000'),float('3.000000'),float('-8.000000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 6 } ], "inspector": [ -274.74711651635141, 95.006012253317778 ], "name": "c0", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 5/22/15", "", "import fab", "", "title('Cube (center)')", "", "input('x', float)", "input('y', float)", "input('z', float)", "input('width', float)", "input('height', float)", "input('depth', float)", "", "xmin, xmax = x - width/2, x + width/2", "ymin, ymax = y - height/2, y + height/2", "zmin, zmax = z - depth/2, z + depth/2", "", "output('shape', fab.shapes.cube(xmin, xmax, ymin, ymax, zmin, zmax))", "", "# UI", "sb.ui.wireframe([(xmin, ymin, zmin), (xmax, ymin, zmin),", " (xmax, ymax, zmin), (xmin, ymax, zmin)], close=True)", "sb.ui.wireframe([(xmin, ymin, zmax), (xmax, ymin, zmax),", " (xmax, ymax, zmax), (xmin, ymax, zmax)], close=True)", "sb.ui.wireframe([(xmin, ymin, zmin), (xmin, ymax, zmin),", " (xmin, ymax, zmax), (xmin, ymin, zmax)], close=True)", "sb.ui.wireframe([(xmax, ymin, zmin), (xmax, ymax, zmin),", " (xmax, ymax, zmax), (xmax, ymin, zmax)], close=True)", "", "def drag_hwd(this, dx,dy,dz):", " this.width += 2*dx", " this.height += 2*dy", " this.depth += 2*dz", "", "sb.ui.point(x, y, z)", "sb.ui.point(x + width/2.0, y + height/2.0, z + depth/2.0,", " drag=drag_hwd)", "", "" ], "uid": 0 } ], "protocol": 6, "type": "sb" }