[Numpy-discussion] normalizing a vector so it has magnitude 1
Gary Ruben
gruben@bigpond.net...
Wed Aug 27 16:18:33 CDT 2008
I don't know what you mean by a 1D vector, but for a 3-vector, you can
do this (also works for N-dimensions)
In [1]: a=r_[1.,2.,3.]
In [2]: a
Out[2]: array([ 1., 2., 3.])
In [3]: b=a/norm(a)
In [4]: b
Out[4]: array([ 0.26726124, 0.53452248, 0.80178373])
Gary R
> bit of a newb question, is there a method for normalising a 1D vector
> so it ends up with magnitude 1?
>
> I can do it manually but I was hoping there was a neat numpy - or
> scipy - trick. I've been web surfing but nothing really leaps out
More information about the Numpy-discussion
mailing list