from k3d import K3D
import numpy
from math import sin, cos, pi
view_matrix = (
10.0, 2.0, -20.0, 0.0,
0.0, 10.0, 0.0, 5.0,
0.0, 0.0, 10.0, 0.0,
0.0, 0.0, 0.0, 1.0
)
width = height = 100
def f(x, y):
return round(0.25 * sin(float(x)/width * 2*pi) + 0.25 * cos(float(y)/height * 2*pi), 3)
scalars_field = [[f(x, y) for y in range(height)] for x in range(width)]
plot = K3D()
plot += K3D.surface(scalars_field, view_matrix=view_matrix, color=0xFF0000)
plot.display()