[Numpy-discussion] Another Array

Ian Mallett geometrian@gmail....
Fri Apr 10 02:07:45 CDT 2009


This seems to work:

vecs = Numeric.random.standard_normal(size=(self.size[0],self.size[1],3))
magnitudes = Numeric.sqrt((vecs*vecs).sum(axis=-1))
uvecs = vecs / magnitudes[...,Numeric.newaxis]
randlen = Numeric.random.random((self.size[0],self.size[1]))
randuvecs = uvecs*randlen[...,Numeric.newaxis]
rgb = ((randuvecs+1.0)/2.0)*255.0

(I have "import numpy as Numeric" for other reasons, that's why there's
Numeric there).

Thanks,
Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090410/84e6aaa1/attachment.html 


More information about the Numpy-discussion mailing list