[Numpy-discussion] Another Array
Fri Apr 10 02:01:10 CDT 2009
On Fri, Apr 10, 2009 at 01:58, Ian Mallett <firstname.lastname@example.org> wrote:
> 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?
> It crashed.
> 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
> make sense.
See how I did magnitudes[...,numpy.newaxis]? You have to do the same.
>> 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
> different directions.
Ah, okay. That makes sense.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion