From: Bruce S. <bas...@nc...> - 2010-09-16 04:54:56
|
I'll immediately offer an alternative. Suppose there is in the visual folder a file vobjects.py containing this: from .primitives import (arrow, cylinder, cone, sphere, box, ring, label, frame, pyramid, ellipsoid, curve, faces, convex, helix, points, text, distant_light, local_light) Then you could do this: import visual.vobjects as vo c = vo.curve(pos=[(0,0,0), (1,0,0), (0,1,0)]) Would this be preferable to the following? from visual.primitives import curve c = curve(pos=[(0,0,0), (1,0,0), (0,1,0)]) Similarly, there could be a visual/vector.py file for the vector stuff (vector, mag, etc.). There are already visual.crayola and visual.materials files of this kind. Bruce Sherwood P.S. You might be wondering where numpy comes into this, considering that for example the pos attribute of curve is a numpy array. The numpy machinery is imported into the C++ component of Visual by __init__.py, which is executed when you import (say) visual.primitive. In the tiny program above, if you print(type(c.pos)) you'll see <class 'numpy.ndarray'>, and if you print(3*c.pos)) you'll see a 3 by 3 array displayed that is 3 times that of c.pos. But your own namespace doesn't contain numpy's array object, and trying to set b = array([1,2,3]) gives an error: array not defined. |