The only problem I see is here:
That's going to generate values from pi to 2pi, rather than 0 to 2pi. You could switch to:Code:alpha = pi*rand() + pi;
Or you could predefine a constant named twopi equal to pi * 2 (so you don't have to constantly recalculate pi * 2 . . . that's what I did in my Java code) and do this:Code:alpha = rand() * (pi + pi);
Everything else looks right. Dr. Cutress seems to have used 10000 individual particles, and they all start with the same coordinates for origin (0, 0, 0). The calculations do not seem to take any kind of particle-on-particle collision into account which is just fine with me.Code:alpha = rand() * twopi;
My rand() is uniformly generated from -1 to 1.
Multiplying by pi creates a uniformly generated distribution from -pi to pi.
Adding pi to it shifts the distribution from 0 to 2*pi.
I will upload a more advanced C++ version in a bit. I need the experience with MT and compilers.
