Wednesday, 5 January 2011

Debugging vectors in 3D

Ever need to figure out the relationship between various 3D vectors? One way to do this is to draw the vectors using VPython.

When you run the following code using VPython's VIdle on Windows, an interactive window pops up where you can rotate the scene by holding down the right mouse button:
from visual import *

floor = box(pos=(0,0,0), length=4, width=4,
xaxis = arrow(pos=(0,0,0), axis=(1,0,0),
yaxis = arrow(pos=(0,0,0), axis=(0,1,0),
Does anyone know a different way to draw and interact with 3D vectors?


Andrew Dalke said...

You can draw vectors like this in VMD. See . I have no idea if the Python API supports the "draw" commands.

steino said...

We use vmd to draw vectors, we hacked together a handy little tcl script which draws the vector with the origin on a given atom and draws a label at the end.

It's extra nice since you can easily draw orbitals and stuff in VMD also.