{ "nodes": [ { "datums": [ { "expr": "5.278325200080872", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-0.8906284272670746", "name": "y0", "type": "float", "uid": 1 }, { "expr": "1.7732303142547607", "name": "width", "type": "float", "uid": 2 }, { "expr": "0.353527", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f4.39171X-Xf6.16494a-f-1.06739Y-Yf-0.713865',float('4.391710'),float('-1.067392'),float('-inf'),float('6.164940'),float('-0.713865'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 642.29093996529286, 539.61523785993404 ], "name": "r0", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/15", "", "import fab", "", "title('Rectangle (center)')", "", "input('x0', float)", "input('y0', float)", "input('width', float)", "input('height', float)", "", "xmin, xmax = x0 - width/2, x0 + width/2", "ymin, ymax = y0 - height/2, y0 + height/2", "", "output('shape', fab.shapes.rectangle(xmin, xmax, ymin, ymax))", "", "def drag_hw(this, x, y, z):", " this.width = abs(2 * (x - this.x0))", " this.height = abs(2 * (y - this.y0))", "", "# UI", "sb.ui.wireframe(", " [(xmin, ymin, 0), (xmax, ymin, 0), (xmax, ymax, 0), (xmin, ymax, 0)],", " close=True)", "sb.ui.point(x0, y0)", "sb.ui.point(xmax, ymax, drag=drag_hw, relative=False)", "" ], "uid": 0 }, { "datums": [ { "expr": "1.149999886751175", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-0.03999999165534973", "name": "y0", "type": "float", "uid": 1 }, { "expr": "1.3596648556033522", "name": "r", "type": "float", "uid": 2 }, { "expr": "0.35367750872410736", "name": "_a", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r+q-Xf1.15q-Yf-0.04f1.35966',float('-0.209665'),float('-1.399665'),float('-inf'),float('2.509665'),float('1.319665'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 660.71262044707021, -38.285117792139566 ], "name": "c0", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/18", "", "import fab", "import math", "", "title('Circle (center)')", "", "input('x0',float)", "input('y0',float)", "input('r',float)", "input('_a',float)", "", "output('shape', fab.shapes.circle(x0, y0, r))", "", "def drag_r(this,x,y,z):", " dx = x - this.x0", " dy = y - this.y0", " this.r = math.sqrt(dx**2 + dy**2)", " this._a = math.atan2(dy, dx)", "", "# UI", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x0,", " math.sin(i/36. * 2*math.pi) * r + y0, 0)", " for i in range(36)], close=True)", "sb.ui.point(x0,y0)", "sb.ui.point(x0 + r*math.cos(_a),", " y0 + r*math.sin(_a),", " drag=drag_r, relative=False)", "", "" ], "uid": 1 }, { "datums": [ { "expr": "0", "name": "x0", "type": "float", "uid": 0 }, { "expr": "0", "name": "y0", "type": "float", "uid": 1 }, { "expr": "0.17796669900417328", "name": "y1", "type": "float", "uid": 2 }, { "expr": "1.3839832544326782", "name": "s0", "type": "float", "uid": 3 }, { "expr": "1.3026552200317383", "name": "s1", "type": "float", "uid": 4 }, { "expr": "\u0011[__1.__4]", "name": "shape", "type": "_fabtypes.Shape", "uid": 5 }, { "expr": "\u0012fab.types.Shape('m+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966',float('-0.424279'),float('-1.399665'),float('-inf'),float('5.078571'),float('1.319665'),float('inf'))", "name": "transform", "type": "_fabtypes.Shape", "uid": 6 } ], "inspector": [ 608.81179438498998, 177.0063920711915 ], "name": "t0", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 5/31/15", "", "import fab", "", "title('Taper (XY)')", "", "input('x0', float)", "input('y0', float)", "input('y1', float)", "input('s0', float)", "input('s1', float)", "", "input('shape', fab.types.Shape)", "output('transform', fab.shapes.taper_x_y(shape, x0, y0, y1, s0, s1))", "", "# UI", "def drag_base(this, dx, dy, dz):", " this.x0 += dx", " this.y0 += dy", " this.y1 += dy", "", "sb.ui.wireframe([(x0 + s0, y0, 0), (x0, y0, 0),", " (x0, y1, 0), (x0 + s1, y1, 0)], color=sb.color.teal)", "sb.ui.point(x0, y0, color=sb.color.teal, drag=drag_base)", "sb.ui.point(x0 + s0, y0, color=sb.color.teal, drag=(s0, None, None))", "sb.ui.point(x0 + s1, y1, color=sb.color.teal, drag=(s1, y1, None))", "" ], "uid": 2 }, { "datums": [ { "expr": "\u0011[__4.__1]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "-0.32", "name": "o", "type": "float", "uid": 1 }, { "expr": "\u0012fab.types.Shape('-m+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966f-0.32',float('-0.424279'),float('-1.399665'),float('-inf'),float('5.078571'),float('1.319665'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 991.01030974890045, 190.53554305752465 ], "name": "o0", "script": [ "import fab.types", "import fab.shapes", "", "title('Offset')", "input('a', fab.types.Shape)", "input('o', float)", "", "output('shape', fab.shapes.offset(a, o))", "" ], "uid": 3 }, { "datums": [ { "expr": "\u0011[__2.__6]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0012fab.types.Shape('m+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966',float('-0.424279'),float('-1.399665'),float('-inf'),float('5.078571'),float('1.319665'),float('inf'))", "name": "copy", "type": "_fabtypes.Shape", "uid": 1 } ], "inspector": [ 980.86344650915055, -31.568018968110593 ], "name": "c1", "script": [ "# Neil Gershenfeld 2/14/15", "# Matt Keeter 6/12/15", "", "import fab", "", "title('Copy')", "", "input('shape', fab.types.Shape)", "output('copy', shape)", "", "" ], "uid": 4 }, { "datums": [ { "expr": "\u0011[__4.__0]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__3.__2]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('am+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966n-m+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966f-0.32',float('-0.424279'),float('-1.399665'),float('-inf'),float('5.078571'),float('1.319665'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 994.39259749548387, 357.39507188896647 ], "name": "d0", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 5 }, { "datums": [ { "expr": "2.44670569896698", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-0.1022738516330719", "name": "y0", "type": "float", "uid": 1 }, { "expr": "1.8381628685302491", "name": "r", "type": "float", "uid": 2 }, { "expr": "-1.568101381690533", "name": "_a", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r+q-Xf2.44671q-Yf-0.102274f1.83816',float('0.608543'),float('-1.940437'),float('-inf'),float('4.284869'),float('1.735889'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 1354.0816084966423, 119.55497704841338 ], "name": "c2", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/18", "", "import fab", "import math", "", "title('Circle (center)')", "", "input('x0',float)", "input('y0',float)", "input('r',float)", "input('_a',float)", "", "output('shape', fab.shapes.circle(x0, y0, r))", "", "def drag_r(this,x,y,z):", " dx = x - this.x0", " dy = y - this.y0", " this.r = math.sqrt(dx**2 + dy**2)", " this._a = math.atan2(dy, dx)", "", "# UI", "sb.ui.wireframe([", " (math.cos(i/36. * 2*math.pi) * r + x0,", " math.sin(i/36. * 2*math.pi) * r + y0, 0)", " for i in range(36)], close=True)", "sb.ui.point(x0,y0)", "sb.ui.point(x0 + r*math.cos(_a),", " y0 + r*math.sin(_a),", " drag=drag_r, relative=False)", "", "" ], "uid": 6 }, { "datums": [ { "expr": "\u0011[__6.__4]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__5.__2]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('a-r+q-Xf2.44671q-Yf-0.102274f1.83816am+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966n-m+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966f-0.32',float('0.608543'),float('-1.399665'),float('-inf'),float('4.284869'),float('1.319665'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 1356.5395322080074, 345.23549597960658 ], "name": "i0", "script": [ "import fab.types", "", "title('Intersection')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & b)", "" ], "uid": 7 }, { "datums": [ { "expr": "0", "name": "y0", "type": "float", "uid": 0 }, { "expr": "1", "name": "y1", "type": "float", "uid": 1 }, { "expr": "0", "name": "dx0", "type": "float", "uid": 2 }, { "expr": "1", "name": "dx1", "type": "float", "uid": 3 }, { "expr": "\u0011[__0.__4]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('m--Xf0/*f1-Yf0f1Y_aa-f4.39171X-Xf6.16494a-f-1.06739Y-Yf-0.713865',float('3.324318'),float('-1.067392'),float('-inf'),float('5.451075'),float('-0.713865'),float('inf'))", "name": "sheared", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 957.18743228306789, 547.930614946491 ], "name": "s0", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 5/31/15", "", "import fab", "", "title('Shear (2D)')", "", "input('y0', float)", "input('y1', float)", "input('dx0', float)", "input('dx1', float)", "", "input('shape', fab.types.Shape)", "output('sheared', fab.shapes.shear_x_y(shape, y0, y1, dx0, dx1))", "", "# UI", "dy = abs(y1 - y0)", "sb.ui.wireframe([(dx0, y0, 0), (dx1, y1, 0)], color=sb.color.teal)", "sb.ui.wireframe([(dx0 - dy/5, y0, 0), (dx0 + dy/5, y0, 0)],", " color=sb.color.teal)", "sb.ui.wireframe([(dx1 - dy/5, y1, 0), (dx1 + dy/5, y1, 0)],", " color=sb.color.teal)", "sb.ui.point(dx0, y0, 0, color=sb.color.teal)", "sb.ui.point(dx1, y1, 0, color=sb.color.teal)", "", "", "", "", "" ], "uid": 8 }, { "datums": [ { "expr": "6.403918743133545", "name": "x", "type": "float", "uid": 0 }, { "expr": "0.1724917578697207", "name": "y", "type": "float", "uid": 1 }, { "expr": "0.1625753864645958", "name": "z", "type": "float", "uid": 2 }, { "expr": "1.0", "name": "r", "type": "float", "uid": 3 }, { "expr": "\u0011[__8.__5]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('m-Xf6.40392-Yf0.172492-Zf0.162575m*X+f1xn/r++qXqYqZf1*Y+f1xn/r++qXqYqZf1*Z+f1xn/r++qXqYqZf1m-Xf-6.40392-Yf-0.172492-Zf-0.162575m--Xf0/*f1-Yf0f1Y_aa-f4.39171X-Xf6.16494a-f-1.06739Y-Yf-0.713865',float('2.956439'),float('-1.435271'),float('-inf'),float('5.818954'),float('-0.345986'),float('inf'))", "name": "attracted", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 1259.3384709778404, 560.33233668396304 ], "name": "a0", "script": [ "import fab", "import math", "", "title('Attract')", "", "input('x', float)", "input('y', float)", "input('z', float)", "input('r', float)", "input('shape', fab.types.Shape)", "", "output('attracted', fab.shapes.attract(shape, 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, color=sb.color.teal)", "", "# Draw little arrows pointing inwards", "sb.ui.wireframe([(x,y,z-r), (x,y,z - 0.2*r)])", "sb.ui.wireframe([(x,y,z+r), (x,y,z + 0.2*r)], color=sb.color.teal)", "sb.ui.wireframe([(x, y + 0.2*r, z - 0.4*r), (x, y, z - 0.2*r),", " (x, y - 0.2*r, z - 0.4*r)], color=sb.color.teal)", "sb.ui.wireframe([(x, y + 0.2*r, z + 0.4*r), (x, y, z + 0.2*r),", " (x, y - 0.2*r, z + 0.4*r)], color=sb.color.teal)", "", "sb.ui.point(x, y, z, color=sb.color.teal)", "sb.ui.point(x, y, z + r, drag=(None, None, r), color=sb.color.teal)", "sb.ui.point(x, y, z - r, drag=(None, None, r), color=sb.color.teal)", "" ], "uid": 9 }, { "datums": [ { "expr": "\u0011[__7.__2]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__9.__5]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "0.53", "name": "q", "type": "float", "uid": 2 }, { "expr": "\u0012fab.types.Shape('iia-r+q-Xf2.44671q-Yf-0.102274f1.83816am+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966n-m+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966f-0.32m-Xf6.40392-Yf0.172492-Zf0.162575m*X+f1xn/r++qXqYqZf1*Y+f1xn/r++qXqYqZf1*Z+f1xn/r++qXqYqZf1m-Xf-6.40392-Yf-0.172492-Zf-0.162575m--Xf0/*f1-Yf0f1Y_aa-f4.39171X-Xf6.16494a-f-1.06739Y-Yf-0.713865-+rba-r+q-Xf2.44671q-Yf-0.102274f1.83816am+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966n-m+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966f-0.32rbm-Xf6.40392-Yf0.172492-Zf0.162575m*X+f1xn/r++qXqYqZf1*Y+f1xn/r++qXqYqZf1*Z+f1xn/r++qXqYqZf1m-Xf-6.40392-Yf-0.172492-Zf-0.162575m--Xf0/*f1-Yf0f1Y_aa-f4.39171X-Xf6.16494a-f-1.06739Y-Yf-0.713865f0.53',float('0.608543'),float('-1.435271'),float('-inf'),float('5.818954'),float('1.319665'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 3 } ], "inspector": [ 1687.0146466656267, 365.4512100770213 ], "name": "b0", "script": [ "import fab.types", "import fab.shapes", "", "title('Blend')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "input('q', float)", "", "output('shape', fab.shapes.blend(a, b, q))", "" ], "uid": 10 }, { "datums": [ { "expr": "5.409107208251953", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-0.6820007509040833", "name": "y0", "type": "float", "uid": 1 }, { "expr": "0.305861", "name": "width", "type": "float", "uid": 2 }, { "expr": "0.108177", "name": "height", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('aa-f5.25618X-Xf5.56204a-f-0.736089Y-Yf-0.627912',float('5.256176'),float('-0.736089'),float('-inf'),float('5.562038'),float('-0.627912'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 854.16583317835637, 857.62732640235231 ], "name": "r1", "script": [ "# Neil Gershenfeld 1/24/15", "# Matt Keeter 6/11/15", "", "import fab", "", "title('Rectangle (center)')", "", "input('x0', float)", "input('y0', float)", "input('width', float)", "input('height', float)", "", "xmin, xmax = x0 - width/2, x0 + width/2", "ymin, ymax = y0 - height/2, y0 + height/2", "", "output('shape', fab.shapes.rectangle(xmin, xmax, ymin, ymax))", "", "def drag_hw(this, x, y, z):", " this.width = abs(2 * (x - this.x0))", " this.height = abs(2 * (y - this.y0))", "", "# UI", "sb.ui.wireframe(", " [(xmin, ymin, 0), (xmax, ymin, 0), (xmax, ymax, 0), (xmin, ymax, 0)],", " close=True)", "sb.ui.point(x0, y0)", "sb.ui.point(xmax, ymax, drag=drag_hw, relative=False)", "" ], "uid": 11 }, { "datums": [ { "expr": "\u0011[__10.__3]", "name": "a", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0011[__11.__4,__14.__5,__18.__5]", "name": "b", "type": "_fabtypes.Shape", "uid": 1 }, { "expr": "\u0012fab.types.Shape('aiia-r+q-Xf2.44671q-Yf-0.102274f1.83816am+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966n-m+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966f-0.32m-Xf6.40392-Yf0.172492-Zf0.162575m*X+f1xn/r++qXqYqZf1*Y+f1xn/r++qXqYqZf1*Z+f1xn/r++qXqYqZf1m-Xf-6.40392-Yf-0.172492-Zf-0.162575m--Xf0/*f1-Yf0f1Y_aa-f4.39171X-Xf6.16494a-f-1.06739Y-Yf-0.713865-+rba-r+q-Xf2.44671q-Yf-0.102274f1.83816am+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966n-m+f0/*-Xf0f0.177967-+*Yf-0.081328f0.246303f0Y_-r+q-Xf1.15q-Yf-0.04f1.35966f-0.32rbm-Xf6.40392-Yf0.172492-Zf0.162575m*X+f1xn/r++qXqYqZf1*Y+f1xn/r++qXqYqZf1*Z+f1xn/r++qXqYqZf1m-Xf-6.40392-Yf-0.172492-Zf-0.162575m--Xf0/*f1-Yf0f1Y_aa-f4.39171X-Xf6.16494a-f-1.06739Y-Yf-0.713865f0.53niiaa-f5.25618X-Xf5.56204a-f-0.736089Y-Yf-0.627912m-Xf0-Yf0-Zf0m+*f0.949995X*f-0.312266Y+*f0.312266X*f0.949995Y_m-Xf-0-Yf-0-Zf0m-Xf-4.70183-Yf2.132-Zf0aa-f5.25618X-Xf5.56204a-f-0.736089Y-Yf-0.627912m-Xf0-Yf0-Zf0m+*f0.659691X*f0.751537Y+*f-0.751537X*f0.659691Y_m-Xf-0-Yf-0-Zf0m-Xf-1.35717-Yf-2.58224-Zf0m-Xf0-Yf0-Zf0m+*f0.949995X*f-0.312266Y+*f0.312266X*f0.949995Y_m-Xf-0-Yf-0-Zf0m-Xf-4.70183-Yf2.132-Zf0aa-f5.25618X-Xf5.56204a-f-0.736089Y-Yf-0.627912',float('0.608543'),float('-1.435271'),float('-inf'),float('5.818954'),float('1.319665'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 2 } ], "inspector": [ 1214.241301023395, 865.86566312531772 ], "name": "d1", "script": [ "import fab.types", "", "title('Difference')", "input('a', fab.types.Shape)", "input('b', fab.types.Shape)", "", "output('shape', a & ~b)", "" ], "uid": 12 }, { "datums": [ { "expr": "\u0011[__11.__4]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0012fab.types.Shape('aa-f5.25618X-Xf5.56204a-f-0.736089Y-Yf-0.627912',float('5.256176'),float('-0.736089'),float('-inf'),float('5.562038'),float('-0.627912'),float('inf'))", "name": "copy", "type": "_fabtypes.Shape", "uid": 1 } ], "inspector": [ 854.31755445529768, 1069.2631225272062 ], "name": "c3", "script": [ "# Neil Gershenfeld 2/14/15", "# Matt Keeter 6/12/15", "", "import fab", "", "title('Copy')", "", "input('shape', fab.types.Shape)", "output('copy', shape)", "", "" ], "uid": 13 }, { "datums": [ { "expr": "0.7072738409042358", "name": "x", "type": "float", "uid": 0 }, { "expr": "1.4500032663345337", "name": "y", "type": "float", "uid": 1 }, { "expr": "0.0", "name": "z", "type": "float", "uid": 2 }, { "expr": "\u0011[__13.__1]", "name": "shape", "type": "_fabtypes.Shape", "uid": 3 }, { "expr": "\u0012fab.types.Shape('m-Xf-4.70183-Yf2.132-Zf0aa-f5.25618X-Xf5.56204a-f-0.736089Y-Yf-0.627912',float('0.554346'),float('1.395911'),float('-inf'),float('0.860208'),float('1.504088'),float('inf'))", "name": "out", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 830.63711051517214, 1236.8478027188637 ], "name": "r2", "script": [ "import fab", "", "title('Recenter')", "", "input('x', float)", "input('y', float)", "input('z', float)", "", "input('shape', fab.types.Shape)", "output('out', fab.shapes.recenter(shape, x, y, z))", "", "# UI", "sb.ui.wireframe([(x, y - 0.3, z),", " (x, y + 0.3, z)], color=sb.color.teal)", "sb.ui.wireframe([(x - 0.3, y, z),", " (x + 0.3, y, z)], color=sb.color.teal)", "sb.ui.wireframe([(x, y, z - 0.3),", " (x, y, z + 0.3)], color=sb.color.teal)", "", "sb.ui.point(x, y, z, color=sb.color.teal)", "" ], "uid": 15 }, { "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": "-18.195843243489275", "name": "a", "type": "float", "uid": 3 }, { "expr": "\u0011[__15.__4]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf0m+*f0.949995X*f-0.312266Y+*f0.312266X*f0.949995Y_m-Xf-0-Yf-0-Zf0m-Xf-4.70183-Yf2.132-Zf0aa-f5.25618X-Xf5.56204a-f-0.736089Y-Yf-0.627912',float('0.962521'),float('1.057495'),float('-inf'),float('1.286869'),float('1.255773'),float('inf'))", "name": "rotated", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 1191, 1247 ], "name": "r3", "script": [ "import fab", "import math", "", "title('Rotate (Z)')", "", "input('x', float)", "input('y', float)", "input('_z', float)", "input('a', float)", "", "input('shape', fab.types.Shape)", "output('rotated', fab.shapes.rotate_z(shape, a, x, y))", "", "# UI", "rad = math.radians(a)", "sb.ui.wireframe([(x + math.cos(rad), y + math.sin(rad), _z),", " (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 + math.sin(math.radians(a_)) * 0.3, _z)", " 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(y - this.y, x - this.x))", "sb.ui.point(x + math.cos(rad), y + math.sin(rad), _z,", " color=sb.color.teal, drag=drag_pt, relative=False)", "", "" ], "uid": 14 }, { "datums": [ { "expr": "\u0011[__14.__5]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf0m+*f0.949995X*f-0.312266Y+*f0.312266X*f0.949995Y_m-Xf-0-Yf-0-Zf0m-Xf-4.70183-Yf2.132-Zf0aa-f5.25618X-Xf5.56204a-f-0.736089Y-Yf-0.627912',float('0.962521'),float('1.057495'),float('-inf'),float('1.286869'),float('1.255773'),float('inf'))", "name": "copy", "type": "_fabtypes.Shape", "uid": 1 } ], "inspector": [ 1199.4809378411171, 1471.7645438026611 ], "name": "c4", "script": [ "# Neil Gershenfeld 2/14/15", "# Matt Keeter 6/12/15", "", "import fab", "", "title('Copy')", "", "input('shape', fab.types.Shape)", "output('copy', shape)", "", "" ], "uid": 16 }, { "datums": [ { "expr": "-0.23247522115707397", "name": "x", "type": "float", "uid": 0 }, { "expr": "-1.4256025886535646", "name": "y", "type": "float", "uid": 1 }, { "expr": "0.0", "name": "z", "type": "float", "uid": 2 }, { "expr": "\u0011[__16.__1]", "name": "shape", "type": "_fabtypes.Shape", "uid": 3 }, { "expr": "\u0012fab.types.Shape('m-Xf-1.35717-Yf-2.58224-Zf0m-Xf0-Yf0-Zf0m+*f0.949995X*f-0.312266Y+*f0.312266X*f0.949995Y_m-Xf-0-Yf-0-Zf0m-Xf-4.70183-Yf2.132-Zf0aa-f5.25618X-Xf5.56204a-f-0.736089Y-Yf-0.627912',float('-0.394649'),float('-1.524745'),float('-inf'),float('-0.070301'),float('-1.326467'),float('inf'))", "name": "out", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ 1202.3470810617646, 1610.7724900040796 ], "name": "r4", "script": [ "import fab", "", "title('Recenter')", "", "input('x', float)", "input('y', float)", "input('z', float)", "", "input('shape', fab.types.Shape)", "output('out', fab.shapes.recenter(shape, x, y, z))", "", "# UI", "sb.ui.wireframe([(x, y - 0.3, z),", " (x, y + 0.3, z)], color=sb.color.teal)", "sb.ui.wireframe([(x - 0.3, y, z),", " (x + 0.3, y, z)], color=sb.color.teal)", "sb.ui.wireframe([(x, y, z - 0.3),", " (x, y, z + 0.3)], color=sb.color.teal)", "", "sb.ui.point(x, y, z, color=sb.color.teal)", "" ], "uid": 17 }, { "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": "48.7237", "name": "a", "type": "float", "uid": 3 }, { "expr": "\u0011[__17.__4]", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf0m+*f0.659691X*f0.751537Y+*f-0.751537X*f0.659691Y_m-Xf-0-Yf-0-Zf0m-Xf-1.35717-Yf-2.58224-Zf0m-Xf0-Yf0-Zf0m+*f0.949995X*f-0.312266Y+*f0.312266X*f0.949995Y_m-Xf-0-Yf-0-Zf0m-Xf-4.70183-Yf2.132-Zf0aa-f5.25618X-Xf5.56204a-f-0.736089Y-Yf-0.627912',float('0.736543'),float('-1.302454'),float('-inf'),float('1.099525'),float('-0.927892'),float('inf'))", "name": "rotated", "type": "_fabtypes.Shape", "uid": 5 } ], "inspector": [ 1502.5887697482333, 1620.5339097392236 ], "name": "r5", "script": [ "import fab", "import math", "", "title('Rotate (Z)')", "", "input('x', float)", "input('y', float)", "input('_z', float)", "input('a', float)", "", "input('shape', fab.types.Shape)", "output('rotated', fab.shapes.rotate_z(shape, a, x, y))", "", "# UI", "rad = math.radians(a)", "sb.ui.wireframe([(x + math.cos(rad), y + math.sin(rad), _z),", " (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 + math.sin(math.radians(a_)) * 0.3, _z)", " 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(y - this.y, x - this.x))", "sb.ui.point(x + math.cos(rad), y + math.sin(rad), _z,", " color=sb.color.teal, drag=drag_pt, relative=False)", "", "" ], "uid": 18 } ], "protocol": 6, "type": "sb" }