{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import k3d\n", "import numpy as np\n", "from numpy import sin,cos,pi\n", "from ipywidgets import interact, interactive, fixed\n", "import ipywidgets as widgets\n", "import time\n", "import math\n", "\n", "plot = k3d.plot()\n", "\n", "T = 1.618033988749895\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)).astype(np.float32)\n", "iso = k3d.marching_cubes(p, level=0.0)\n", "plot += iso\n", "plot.display()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.camera_auto_fit = False\n", "p.min(),p.max(),p.shape" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt_vol = k3d.volume(p.astype(np.float32), color_range=[-0.5, 0.5],\n", " color_map=np.array(k3d.basic_color_maps.Jet, dtype=np.float32))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot += plt_vol" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "p[:,:,:45] = 2\n", "plt_vol.volume = p.copy()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.5" } }, "nbformat": 4, "nbformat_minor": 2 }