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()

plot.camera_auto_fit = False

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))
iso = k3d.marching_cubes(p.astype(np.float32),xmin=xmin,xmax=xmax,ymin=ymin,ymax=ymax, zmin=zmin, zmax=zmax, level=0.0)
plot += iso

plot.display()
In [ ]:
@interact(x=widgets.FloatSlider(value=0,min=-3,max=4,step=0.01))
def g(x):
    iso.level=x
    
@interact(rad=widgets.FloatSlider(value=0,min=0,max=2*math.pi,step=0.01))
def g(rad):
    plot.camera = [3*r*sin(rad),3*r*cos(rad),0,
                   0,0,0,
                   0,0,1] 
    
In [ ]:
# camera [posx,posy,posz,targetx,targety,targetz,upx,upy,upz]
In [ ]:
plot.reset_camera()
In [ ]: