{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import k3d\n", "import numpy as np\n", "from ipywidgets import interact, interactive, fixed\n", "import ipywidgets as widgets\n", "import time\n", "plot = k3d.plot()\n", "\n", "\n", "T = 1.618033988749895\n", "from numpy import sin,cos,pi\n", "r = 4.77\n", "zmin,zmax = -r,r\n", "xmin,xmax = -r,r\n", "ymin,ymax = -r,r\n", "Nx,Ny,Nz = 77,77,77\n", "\n", "x = np.linspace(xmin,xmax,Nx)\n", "y = np.linspace(ymin,ymax,Ny)\n", "z = np.linspace(zmin,zmax,Nz)\n", "x,y,z = np.meshgrid(x,y,z,indexing='ij')\n", "p = 2 - (cos(x + T*y) + cos(x - T*y) + cos(y + T*z) + cos(y - T*z) + cos(z - T*x) + cos(z + T*x))\n", "iso = k3d.marching_cubes(p,xmin=xmin,xmax=xmax,ymin=ymin,ymax=ymax, zmin=zmin, zmax=zmax, level=0.0)\n", "plot += iso\n", "@interact(x=widgets.FloatSlider(value=0,min=-3,max=4,step=0.01))\n", "def g(x):\n", " iso.level=x\n", "\n", "plot.display()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.0" } }, "nbformat": 4, "nbformat_minor": 1 }