[Numpy-discussion] Another Array

Ian Mallett geometrian@gmail....
Fri Apr 10 01:58:21 CDT 2009


On Thu, Apr 9, 2009 at 11:46 PM, Robert Kern <robert.kern@gmail.com> wrote:

> Parabolic? They should be spherical.

The particle system in the last screenshot was affected by gravity.  In the
absence of gravity, the results should be spherical, yes.  All the vectors
are a unit length, which produces a perfectly smooth surface (unrealistic
for such an effect).

> No, it's not obvious. Exactly what code did you try? What results did
> you get? What results were you expecting?

It crashed.
I have this code:
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 #It crashes here with a dimension mismatch
rgb = ((randvecs+1.0)/2.0)*255.0

I also tried randlen = Numeric.random.random((self.size[0],self.size[1],3)),
but this does not scale each of the vector's components equally, producing
artifacts again.  Each needs to be scaled by the same random value for it to
make sense.

> Let's take a step back. What kind of distribution are you trying to
> achieve? You asked for uniformly distributed unit vectors. Now you are
> asking for something else, but I'm really not sure what. What standard
> are you comparing against when you say that the unit vectors look
> "unrealistic"?

The vectors are used to "jitter" each particle's initial speed, so that the
particles go in different directions instead of moving all as one.  Using
the unit vector causes the particles to make the smooth parabolic shape.
The jitter vectors much then be of a random length, so that the particles go
in all different directions at all different speeds, instead of just all in
different directions.

Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090409/8d6bd931/attachment.html 


More information about the Numpy-discussion mailing list