{ "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": "0.25", "name": "R", "type": "float", "uid": 3 }, { "expr": "0.3", "name": "r", "type": "float", "uid": 4 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf0-r+q-f0.25r+qXqYqZf0.3',float('-0.550000'),float('-0.550000'),float('-0.300000'),float('0.550000'),float('0.550000'),float('0.300000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ -463.8203125, -80 ], "name": "t0", "script": [ "# Neil Gershenfeld 1/25/15", "# Matt Keeter 5/31/15", "", "import fab", "import math", "", "title('Torus (Z)')", "", "input('x', float)", "input('y', float)", "input('z', float)", "input('R', float)", "input('r', float)", "", "output('shape', fab.shapes.torus_z(x, y, z, R, r))", "", "# UI", "sb.ui.wireframe([", " (x,", " math.sin(i/36. * 2*math.pi) * r + y + R,", " math.cos(i/36. * 2*math.pi) * r + z)", " for i in range(36)], close=True)", "sb.ui.wireframe([", " (math.sin(i/36. * 2*math.pi) * R + x,", " math.cos(i/36. * 2*math.pi) * R + y,", " z)", " for i in range(36)], close=True)", "sb.ui.wireframe([(x, y, z), (x, y, z + R + r)])", "sb.ui.point(x, y, z)", "sb.ui.point(x, y + R, z, drag=(None, R, None))", "sb.ui.point(x, y + R + r, z, drag=(None, r, None))", "", "" ], "uid": 0 }, { "datums": [ { "expr": "0.034932076930999756", "name": "_x", "type": "float", "uid": 0 }, { "expr": "0.10742631182074547", "name": "_y", "type": "float", "uid": 1 }, { "expr": "-0.16978700459003448", "name": "z0", "type": "float", "uid": 2 }, { "expr": "1.9", "name": "s", "type": "float", "uid": 3 }, { "expr": "\u0011[__0.__5]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('mXY+f-0.169787/-Zf-0.169787f1.9m-Xf0-Yf0-Zf0-r+q-f0.25r+qXqYqZf0.3',float('-0.550000'),float('-0.550000'),float('-0.417192'),float('0.550000'),float('0.550000'),float('0.722808'))", "name": "scaled", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ -175, -65 ], "name": "s0", "script": [ "import fab", "", "title('Scale (Z)')", "", "input('_x', float)", "input('_y', float)", "input('z0', float)", "input('s', float)", "input('shape', fab.types.Shape)", "output('scaled', fab.shapes.scale_z(shape, z0, s))", "", "# UI", "kwargs = {'color':sb.color.teal}", "sb.ui.wireframe([(_x + 0.2*s, _y, z0), (_x - 0.2*s, _y, z0)], **kwargs)", "sb.ui.wireframe([(_x, _y, z0), (_x, _y, z0 + s)], **kwargs)", "sb.ui.wireframe([(_x - 0.1*s, _y, z0 + 0.9*s), (_x, _y, z0 + s),", " (_x + 0.1*s, _y, z0 + 0.9*s)], **kwargs)", "", "sb.ui.point(_x, _y, z0, color=sb.color.teal)", "sb.ui.point(_x, _y, z0 + s, color=sb.color.teal, drag=(None,None,s))", "" ], "uid": 1 }, { "datums": [ { "expr": "0.07565391063690186", "name": "x", "type": "float", "uid": 0 }, { "expr": "0.2619829550385475", "name": "y", "type": "float", "uid": 1 }, { "expr": "0.22624089568853378", "name": "z", "type": "float", "uid": 2 }, { "expr": "0.3554637983441353", "name": "r", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r++q-Xf0.0756539q-Yf0.261983q-Zf0.226241f0.355464',float('-0.279810'),float('-0.093481'),float('-0.129223'),float('0.431118'),float('0.617447'),float('0.581705'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -426.8203125, 174 ], "name": "s1", "script": [ "import fab", "import math", "", "title('Sphere (center)')", "", "input('x', float)", "input('y', float)", "input('z', float)", "input('r', float)", "", "output('shape', fab.shapes.sphere(x, y, z, r))", "", "# UI", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x,", " math.sin(i/36. * 2*math.pi) * r + y, z)", " for i in range(36)], close=True)", "sb.ui.wireframe([(x,y,z-r), (x,y,z+r)])", "", "sb.ui.point(x, y, z)", "sb.ui.point(x, y, z + r, drag=(None, None, r))", "sb.ui.point(x, y, z - r, drag=(None, None, r))", "" ], "uid": 2 }, { "datums": [ { "expr": "\u0011[__1.__5]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__2.__4]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('amXY+f-0.169787/-Zf-0.169787f1.9m-Xf0-Yf0-Zf0-r+q-f0.25r+qXqYqZf0.3n-r++q-Xf0.0756539q-Yf0.261983q-Zf0.226241f0.355464',float('-0.550000'),float('-0.550000'),float('-0.417192'),float('0.550000'),float('0.550000'),float('0.722808'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 65, 144 ], "name": "d0", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 3 }, { "datums": [ { "expr": "0.0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0.0", "name": "y", "type": "float", "uid": 1 }, { "expr": "0.0", "name": "zmin", "type": "float", "uid": 2 }, { "expr": "0.9", "name": "zmax", "type": "float", "uid": 3 }, { "expr": "0.03", "name": "r", "type": "float", "uid": 4 }, { "expr": "\u0012fab.types.Shape('am__f1-r+qXqYf0.03a-f0Z-Zf0.9',float('-0.030000'),float('-0.030000'),float('0.000000'),float('0.030000'),float('0.030000'),float('0.900000'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ -137.8203125, -348 ], "name": "c0", "script": [ "import fab", "import math", "", "title('Cylinder (Z)')", "", "input('x', float)", "input('y', float)", "input('zmin', float)", "input('zmax', float)", "input('r', float)", "", "output('shape', fab.shapes.cylinder(x, y, zmin, zmax, r))", "", "# UI", "sb.ui.wireframe([(x, y, zmin), (x, y, zmax)])", "sb.ui.wireframe([(x, y, zmin), (x+r, y, zmin)])", "", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x,", " math.sin(i/36. * 2*math.pi) * r + y, zmin)", " for i in range(36)], close=True)", "", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x,", " math.sin(i/36. * 2*math.pi) * r + y, zmax)", " for i in range(36)], close=True)", "", "sb.ui.point(x, y, zmin)", "sb.ui.point(x, y, zmax)", "sb.ui.point(x + r, y, zmin, drag=(r, None, None))", "" ], "uid": 4 }, { "datums": [ { "expr": "\u0011[__7.__5]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__3.__2]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('im-Xf0-Yf0-Zf0m_+*f0.999391Y*f-0.0348995Z+*f0.0348995Y*f0.999391Zm-Xf0-Yf-0-Zf-0am__f1-r+qXqYf0.03a-f0Z-Zf0.9amXY+f-0.169787/-Zf-0.169787f1.9m-Xf0-Yf0-Zf0-r+q-f0.25r+qXqYqZf0.3n-r++q-Xf0.0756539q-Yf0.261983q-Zf0.226241f0.355464',float('-0.550000'),float('-0.550000'),float('-0.417192'),float('0.550000'),float('0.550000'),float('0.900499'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 459.61069814731036, -402.12025919862526 ], "name": "u0", "script": [ "import fab.types", "", "title('Union')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a | b)", "" ], "uid": 5 }, { "datums": [ { "expr": "\u0011[__5.__2]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0012fab.types.Shape('im-Xf0-Yf0-Zf0m_+*f0.999391Y*f-0.0348995Z+*f0.0348995Y*f0.999391Zm-Xf0-Yf-0-Zf-0am__f1-r+qXqYf0.03a-f0Z-Zf0.9amXY+f-0.169787/-Zf-0.169787f1.9m-Xf0-Yf0-Zf0-r+q-f0.25r+qXqYqZf0.3n-r++q-Xf0.0756539q-Yf0.261983q-Zf0.226241f0.355464',float('-0.550000'),float('-0.550000'),float('-0.417192'),float('0.550000'),float('0.550000'),float('0.900499'))", "name": "out", "type": "_fabtypes.Shape", "uid": 1 } ], "inspector": [ 508.92296125231127, -51.253160534249844 ], "name": "m0", "script": [ "import fab", "", "title('Mesh (.stl)')", "", "input('shape', fab.types.Shape)", "output('out', shape)", "", "sb.export.stl(shape)", "" ], "uid": 6 }, { "datums": [ { "expr": "0.0", "name": "_x", "type": "float", "uid": 0 }, { "expr": "0", "name": "y", "type": "float", "uid": 1 }, { "expr": "0.0", "name": "z", "type": "float", "uid": 2 }, { "expr": "-2", "name": "a", "type": "float", "uid": 3 }, { "expr": "\u0011[__4.__5]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf0m_+*f0.999391Y*f-0.0348995Z+*f0.0348995Y*f0.999391Zm-Xf0-Yf-0-Zf-0am__f1-r+qXqYf0.03a-f0Z-Zf0.9',float('-0.030000'),float('-0.029982'),float('-0.001047'),float('0.030000'),float('0.061391'),float('0.900499'))", "name": "rotated", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 147.16877368949991, -320.50102702856145 ], "name": "r0", "script": [ "import fab", "import math", "", "title('Rotate (X)')", "", "input('_x', float)", "input('y', float)", "input('z', float)", "input('a', float)", "", "input('shape', fab.types.Shape)", "output('rotated', fab.shapes.rotate_x(shape, a, y, z))", "", "# UI", "rad = math.radians(a)", "sb.ui.wireframe([(_x, y + math.cos(rad), z + math.sin(rad)),", " (_x, y, z),", " (_x, y + 1, z)], color=sb.color.teal)", "", "# Draw a semi-circular arc showing the rotation", "if int(a) % 360 != 0:", " sb.ui.wireframe([", " (_x, y + math.cos(math.radians(a_)) * 0.3,", " 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, y - this.y))", "sb.ui.point(_x, y + math.cos(rad), z + math.sin(rad),", " color=sb.color.teal, drag=drag_pt, relative=False)", "", "" ], "uid": 7 } ], "protocol": 6, "type": "sb" }