[Numpy-discussion] Another Array
Fri Apr 10 01:58:21 CDT 2009
On Thu, Apr 9, 2009 at 11:46 PM, Robert Kern <email@example.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?
I have this code:
vecs = Numeric.random.standard_normal(size=(self.size,self.size,3))
magnitudes = Numeric.sqrt((vecs*vecs).sum(axis=-1))
uvecs = vecs / magnitudes[...,Numeric.newaxis]
randlen = Numeric.random.random((self.size,self.size))
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,self.size,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
> 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
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion