+{"metadata":{"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"file_extension":".py","nbconvert_exporter":"python","codemirror_mode":{"name":"ipython","version":3},"name":"python","pygments_lexer":"ipython3","mimetype":"text/x-python","version":"3.12.1"}},"nbformat_minor":5,"nbformat":4,"cells":[{"id":"9c2f0c0c-4898-4122-9c2a-f0f77ea52094","cell_type":"code","source":"from vpython import *\nscene = canvas() # This is needed in Jupyter notebook and lab to make programs easily rerunnable\n# Kadir Haldenbilen, Feb. 2011\n\nscene.height = scene.width = 600\nscene.background = color.gray(0.7)\nscene.range = 3\nscene.ambient = 0.5*color.white\n\nscene.caption = \"\"\"To rotate \"camera\", drag with right button or Ctrl-drag.\nTo zoom, drag with middle button or Alt/Option depressed, or use scroll wheel.\n On a two-button mouse, middle is left + right.\nTo pan left/right and up/down, Shift-drag.\nTouch screen: pinch/extend to zoom, swipe or two-finger rotate.\"\"\"\n\ndef spiral(nloop=1, tightness=1.0, dir=1, scale=1):\n spr = []\n scale = []\n clrs = []\n zd = 0.01\n for t in range(1, 1024*nloop, 16):\n t *= 0.01\n x = tightness/10 * t * cos(t)*dir\n y = tightness/10 * t * sin(t)\n sc = sqrt(x*x+y*y)\n z = t/7\n spr.append(vector(x,y,z))\n clr = vector(z*cos(t), abs(sin(t)), abs(cos(t*2))).norm()\n clrs.append(clr)\n scale.append(sc)\n return spr, scale, clrs\n\npath, scale, clrs = spiral(nloop=2, tightness=0.8)\nelps = shapes.circle(radius=0.69, thickness=0.01)\n\nee = extrusion(shape=elps, path=path, color=clrs, scale=scale, texture=textures.rock)\nee.rotate(angle=pi/2)\nscene.center = ee.pos-vec(0,.5,0)\n\n","metadata":{"trusted":false},"outputs":[{"data":{"text/html":"<div id=\"glowscript\" class=\"glowscript\"></div>","text/plain":"<IPython.core.display.HTML object>"},"metadata":{},"output_type":"display_data"},{"metadata":{},"data":{"application/javascript":"if (typeof Jupyter !== \"undefined\") { window.__context = { glowscript_container: $(\"#glowscript\").removeAttr(\"id\")};}else{ element.textContent = ' ';}","text/plain":"<IPython.core.display.Javascript object>"},"output_type":"display_data"},{"data":{"text/plain":"<IPython.core.display.HTML object>","text/html":"<div id=\"glowscript\" class=\"glowscript\"></div>"},"metadata":{},"output_type":"display_data"},{"metadata":{},"output_type":"display_data","data":{"text/plain":"<IPython.core.display.Javascript object>","application/javascript":"if (typeof Jupyter !== \"undefined\") { window.__context = { glowscript_container: $(\"#glowscript\").removeAttr(\"id\")};}else{ element.textContent = ' ';}"}}],"execution_count":1},{"id":"d01c51ea-d6a6-4d7f-aac1-de28cf657c72","cell_type":"code","source":"","metadata":{"trusted":false},"outputs":[],"execution_count":null}]}
0 commit comments