In [1]:
import k3d
import numpy as np

X, Y, Z = np.mgrid[:30, :30, :30]
# scaled distance from the "center" (15, 15, 15) of this scalar field
scalar_field = ((X-15.0)/15.0)**2 + ((Y-15.0)/15.0)**2 + ((Z-15.0)/15.0)**2

plot = k3d.plot()
plot += k3d.marching_cubes(scalar_field.astype(np.float32), level=0.8)
plot.display()
In [2]:
plot.objects[0].level = 0.5
In [3]:
plot.objects[0].wireframe = True
In [4]:
plot.objects[0].flat_shading = False
In [5]:
plot.camera_no_pan = True
In [6]:
plot.camera_no_rotate = True
In [7]:
plot.camera_no_zoom = True
In [8]:
plot.camera_no_pan = False
plot.camera_no_rotate = False
plot.camera_no_zoom = False
In [9]:
plt = plot.objects[0]
In [11]:
type(plt.wireframe)
Out[11]:
bool
In [12]:
plt.scalar_field = ((X**2-15.0)/15.0)**2 + ((Y-15.0)/15.0)**2 + ((Z-15.0)/15.0)**2
/Users/marcin/anaconda3/lib/python3.7/site-packages/traittypes/traittypes.py:101: UserWarning: Given trait value dtype "float64" does not match required type "float32". A coerced copy has been created.
  np.dtype(self.dtype).name))
In [18]:
plt_line = k3d.line([[0,0,0],[1,2,3]])
In [21]:
type(plt_line.vertices)
Out[21]:
numpy.ndarray
In [20]:
 
In [ ]: