From: Symion <kn...@ip...> - 2009-09-05 13:24:03
|
Aaron Miller wrote: > Hi VPython folks, > > I was attempting to run the contributed script > http://vpython.org/contributed/bodies.py and I get an error... I have > tracked it down to the fact that the dot product dot(a,b) between two > vectors returns a type of numpy.float64 and when I multiply this by a > vector I get back an array instead of a vector. > > A simple example that generates an error for me: > > from visual import * > a=vector(1,0,0) > b=dot(a,a)*a > b.mag > > Here is the error: > Traceback (most recent call last): > File "Untitled", line 4 > b.mag > AttributeError: 'numpy.ndarray' object has no attribute 'mag' > > Of course, by assigning b as vector(dot(a,a)*a) we fix this, but it > seems this should not be needed. Is this a bug? > > Thanks, > Aaron > Python 2.6.2 with VPython 5.12 > > ------------------------------------------------------ > Aaron J. Miller, Ph.D. > Department of Physics > 328 Palenske Hall > Albion College, Albion, MI 49224 > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > ------------------------------------------------------------------------ > > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > Try this. from visual import * a=vector(1,0,0) b=vector(dot(a,a)*a) b.mag Symion |