Even though I was curious to hear of both, I probably should have mentioned from the beginning that the forward vector doesn't change for each particle. It is generated when a projectile (bullet) makes contact with another object. The particles spew off of the collision surface. In this case, when a bullet smashes into marble tiling, pieces of marble and dust go flying.
Quote:Original post by mooserman352
..then all you need to do is generate a random angle between 0 and 2*pi. then you have x = cos(theta) y = sin(theta), and so your final vector is x*up + y*right.
This is the solution I'm looking for. And this little bit of math is the only math needed for each particle. Just generate the vectors and randomly rotate around them. Perfect.
Quote:Note, just for principle, that you can also adapt "smashing into planes" algorithm with this, except you would want to use spherical coordinates to generate vectors only on the unit sphere.
If you mean to smash the velocity vector to a half-unit sphere facing the forward vector, then that would introduce some forward velocity (if I understand correctly). The scaling for velocity is plugged in from an outside source, and the forward velocity is a seperate scaler value from the outward velocity. So I don't want to introduce any of one through the other's scale.
Quote:Original post by erissian
Assuming m is the desired magnitude of the random vector,
r = 1-2*rand();
s = 1-2*rand();
t = sqrt(m*m-r*r-s*s) * -rand()%2;
Vector perp(y*t-z*s,z*r-x*t,x*s-y*r);
It's still the cross product, but in four lines and normalized.
I appreciate the time you spent on this, but the math envolved is pretty much the same that's been previously posted. Just yanked out of explicit functions. As I've stated, I'm not trying to optimize. I'm looking for a simpler operation. This doesn't seem to be moving in that direction.
Quote:Original post by erissian
Even for hundreds of particles, I'm sure it pales in comparison to the number of flops you're doing updating the rest of the system.
Your assumptions are irrelevant to the topic, Mr. Negative [grin]
Quote:Original post by Zipster
Technically, the following is an equivalent solution using cross-products:
Vector random(rand(), rand(), rand());Velocity = Cross(forward, random);
This is nice as well. Just a normalize at the end and it's all good.
I appreciate all of the help. I think I'll try the clock-face spin-on-the-plane-dot approach.