In [ ]:
import k3d
import numpy as np
from numpy import sin,cos,pi
from ipywidgets import interact, interactive, fixed
import ipywidgets as widgets
import time
import math

plot = k3d.plot()

T = 1.618033988749895
r = 4.77
zmin,zmax = -r,r
xmin,xmax = -r,r
ymin,ymax = -r,r
Nx,Ny,Nz = 77,77,77

x = np.linspace(xmin,xmax,Nx)
y = np.linspace(ymin,ymax,Ny)
z = np.linspace(zmin,zmax,Nz)
x,y,z = np.meshgrid(x,y,z,indexing='ij')
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)
iso = k3d.marching_cubes(p, level=0.0)
plot += iso
plot.display()
In [ ]:
plot.camera_auto_fit = False
p.min(),p.max(),p.shape
In [ ]:
plt_vol = k3d.volume(p.astype(np.float32), color_range=[-0.5, 0.5],
                     color_map=np.array(k3d.basic_color_maps.Jet, dtype=np.float32))
In [ ]:
plot += plt_vol
In [ ]:
p[:,:,:45] = 2
plt_vol.volume = p.copy()
In [ ]: