{ "nodes": [ { "datums": [ { "expr": "0", "name": "x", "type": "float", "uid": 0 }, { "expr": "0", "name": "y", "type": "float", "uid": 1 }, { "expr": "6", "name": "N", "type": "int", "uid": 2 }, { "expr": "2", "name": "r", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf0aaaaam-Xf0-Yf0-Zf0m+*f1X*f0Y+*f-0X*f1Y_m-Xf0-Yf0-Zf0-f-1.73205Ym-Xf0-Yf0-Zf0m+*f0.5X*f0.866025Y+*f-0.866025X*f0.5Y_m-Xf0-Yf0-Zf0-f-1.73205Ym-Xf0-Yf0-Zf0m+*f-0.5X*f0.866025Y+*f-0.866025X*f-0.5Y_m-Xf0-Yf0-Zf0-f-1.73205Ym-Xf0-Yf0-Zf0m+*f-1X*f1.22465e-16Y+*f-1.22465e-16X*f-1Y_m-Xf0-Yf0-Zf0-f-1.73205Ym-Xf0-Yf0-Zf0m+*f-0.5X*f-0.866025Y+*f0.866025X*f-0.5Y_m-Xf0-Yf0-Zf0-f-1.73205Ym-Xf0-Yf0-Zf0m+*f0.5X*f-0.866025Y+*f0.866025X*f0.5Y_m-Xf0-Yf0-Zf0-f-1.73205Y',float('-2.000000'),float('-2.000000'),float('-inf'),float('2.000000'),float('2.000000'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -629.10552086448865, -386.70823235935416 ], "name": "p0", "script": [ "# Neil Gershenfeld 2/14/15", "# Matt Keeter 6/12/15", "", "import fab", "import math", "", "title('Polygon')", "", "input('x', float)", "input('y', float)", "input('N', int)", "input('r', float)", "", "output('shape', fab.shapes.move(fab.shapes.polygon_radius(x, y, r, N), x, y))", "", "# UI", "# (we need to do a bit of work to make the UI work for both even and", "# odd vertex counts; otherwise it will be off for one or the other)", "a_ = 0 if (N % 2) else (math.pi / N)", "sb.ui.wireframe([", " (x + r * math.sin(a_ + a * math.pi * 2/N),", " y + r * math.cos(a_ + a * math.pi * 2/N), 0)", " for a in range(N)], close=True)", "sb.ui.point(x, y)", "sb.ui.point(x + r * math.sin(a_), y + r * math.cos(a_),", " drag=(None, r, None))", "" ], "uid": 0 }, { "datums": [ { "expr": "-0.49450576305389404", "name": "x0", "type": "float", "uid": 0 }, { "expr": "1.720454603433609", "name": "y0", "type": "float", "uid": 1 }, { "expr": "0.15", "name": "r", "type": "float", "uid": 2 }, { "expr": "0.37852787381187347", "name": "_a", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r+q-Xf-0.494506q-Yf1.72045f0.15',float('-0.644506'),float('1.570455'),float('-inf'),float('-0.344506'),float('1.870455'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -299.89618019705011, -74.410330424831997 ], "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": "1.8572293519973755", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-0.3429267406463623", "name": "y0", "type": "float", "uid": 1 }, { "expr": "\u0011[__1.__2]", "name": "r", "type": "float", "uid": 2 }, { "expr": "0.37852787381187347", "name": "_a", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r+q-Xf1.85723q-Yf-0.342927f0.15',float('1.707229'),float('-0.492927'),float('-inf'),float('2.007229'),float('-0.192927'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -302.2979019345222, -227.88757150969016 ], "name": "c1", "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": 2 }, { "datums": [ { "expr": "-2.8804218769073486", "name": "x0", "type": "float", "uid": 0 }, { "expr": "-1.0078061819076538", "name": "y0", "type": "float", "uid": 1 }, { "expr": "\u0011[__2.__2]", "name": "r", "type": "float", "uid": 2 }, { "expr": "0.37852787381187347", "name": "_a", "type": "float", "uid": 3 }, { "expr": "\u0012fab.types.Shape('-r+q-Xf-2.88042q-Yf-1.00781f0.15',float('-3.030422'),float('-1.157806'),float('-inf'),float('-2.730422'),float('-0.857806'),float('inf'))", "name": "shape", "type": "_fabtypes.Shape", "uid": 4 } ], "inspector": [ -300.18990667654975, -385.87452958999273 ], "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": 3 }, { "datums": [ { "expr": "\u0011[__1.__4,__2.__4,__3.__4]", "name": "shape", "type": "_fabtypes.Shape", "uid": 0 }, { "expr": "0.0", "name": "_x", "type": "float", "uid": 1 }, { "expr": "0.0", "name": "_y", "type": "float", "uid": 2 }, { "expr": "3", "name": "i", "type": "int", "uid": 3 }, { "expr": "1", "name": "j", "type": "int", "uid": 4 }, { "expr": "0.5", "name": "dx", "type": "float", "uid": 5 }, { "expr": "0", "name": "dy", "type": "float", "uid": 6 }, { "expr": "\u0012fab.types.Shape('m-Xf0-Yf0-Zf0m-Xf0-Yf0-Zf0iim-Xf0-Yf0-Zf0ii-r+q-Xf-0.494506q-Yf1.72045f0.15-r+q-Xf1.85723q-Yf-0.342927f0.15-r+q-Xf-2.88042q-Yf-1.00781f0.15m-Xf0.5-Yf0-Zf0ii-r+q-Xf-0.494506q-Yf1.72045f0.15-r+q-Xf1.85723q-Yf-0.342927f0.15-r+q-Xf-2.88042q-Yf-1.00781f0.15m-Xf1-Yf0-Zf0ii-r+q-Xf-0.494506q-Yf1.72045f0.15-r+q-Xf1.85723q-Yf-0.342927f0.15-r+q-Xf-2.88042q-Yf-1.00781f0.15',float('-3.030422'),float('-1.157806'),float('-inf'),float('3.007229'),float('1.870455'),float('inf'))", "name": "array", "type": "_fabtypes.Shape", "uid": 7 } ], "inspector": [ 73.282901175970906, -267.20073198007856 ], "name": "a0", "script": [ "import fab", "", "title('Array (2D)')", "", "input('shape', fab.types.Shape)", "input('_x', float)", "input('_y', float)", "input('i', int)", "input('j', int)", "input('dx', float)", "input('dy', float)", "", "output('array', fab.shapes.iterate3d(shape, i, j, 1, dx, dy, 0))", "", "# UI", "sb.ui.wireframe([", " (_x + dx, _y, 0), (_x, _y, 0), (_x, _y + dy, 0)], color=sb.color.teal)", "sb.ui.wireframe([", " (_x + dx, _y - 0.3, 0), (_x + dx, _y + 0.3, 0)], color=sb.color.teal)", "sb.ui.wireframe([", " (_x + 0.3, _y + dy, 0), (_x - 0.3, _y + dy, 0)], color=sb.color.teal)", "", "sb.ui.point(_x, _y, 0, color=sb.color.teal)", "sb.ui.point(_x + dx, _y, 0, color=sb.color.teal, drag=(dx, None, None))", "sb.ui.point(_x, _y + dy, 0, color=sb.color.teal, drag=(None, dy, None))", "" ], "uid": 4 } ], "protocol": 6, "type": "sb" }