from k3d import K3D
from math import sqrt, sin, cos
width = height = length = 100
voxels = []
color_map = (
(0.7, 0.5, 0.0),
(1.0, 0.0, 0.0)
)
for z in range(length):
for y in range(height):
for x in range(width):
r = sqrt((x - width / 2) * (x - width / 2) + (y - height / 2) * (y - height / 2) + (z - length / 2) * (z - length / 2))
r += sin(x / 2) * 3
r += cos(y / 10) * 5
if r > width / 2:
voxels.append(0)
elif y + sin(x / 20) * 10 > height / 2:
voxels.append(1)
else:
voxels.append(2)
plot = K3D()
plot += K3D.voxels(voxels, color_map, width, height, length)
plot.display()