import numpy as np
from vispy import scene, app
def sincos(x, y, t):
return np.cos(x[:, np.newaxis] + t)*np.cos(y[np.newaxis, :])
if __name__ == '__main__':
nx, ny, scale = 100, 200, 3
x = np.linspace(0., 2.*np.pi, nx)
y = np.linspace(0., np.pi, ny)
dt = .1
t = 0.
canvas = scene.SceneCanvas(keys='interactive')
canvas.size = nx*scale, ny*scale
view = canvas.central_widget.add_view()
def update(event):
global t
canvas.title = "Solution t={0:f}".format(t)
image = scene.visuals.Image(sincos(x, y, t).T, parent=view.scene)
#tr = scene.transforms.AffineTransform()
#tr.rotate(-90, (0, 0, 1))
#tr.translate ??
#image.transform = tr
view.camera = scene.PanZoomCamera(aspect=1)
t += dt
timer = app.Timer('auto', connect=update, start=True)
canvas.show()
app.run()- How can I avoid the transpose of my array ? I try to set an AffineTransform without success.
- What is the best way to speedup the animation ? It seems that create an image at each time slows down the animation.
- Is it possible to update a scene without to create an app and execute app.run() ? In other words, I would like that my code set a refresh of the scene when the computation for a given time step is finished.
On Wed, Apr 29, 2015 at 4:25 AM, Loïc Gouarin <loic.g...@gmail.com> wrote:- How can I avoid the transpose of my array ? I try to set an AffineTransform without success.A transpose is a 180-degree rotation around the x=y line, so:tr.rotate(180, (1, 1, 0))
view.camera = scene.PanZoomCamera(aspect=1)