[vtk-developers] Inconsistency in numpy_support

Prabhu Ramachandran prabhu at aero.iitb.ac.in
Mon Jan 12 07:35:33 EST 2009


Berk Geveci wrote:
> So, how would you do normalize a VTK vector using numpy? Like this?
> 
> v / sqrt(v[:,0]**2+v[:,1]**2+v[:,2]**2).reshape(v.shape[0], 1)

I would do it like this:

v/sqrt(sum(v*v, 1))[:,None]

> It is the reshape call (or any other re-indexing) that I don't like.
> Is there a better way of doing this?

Not sure if the reshape can be avoided.  I think it is better to ask the 
numpy experts this on the appropriate list.

cheers,
prabhu



More information about the vtk-developers mailing list