Hi guys!
I'm looking for the formula for a spherical explosion (particles expanding like a sphere). I'm currently using:
public void pickDirection()
{
float angle = random(0, MathHelper.TwoPi);
float zAngle = random(-MathHelper.PiOver2, MathHelper.PiOver2);
return new Vector3((float)Math.Cos(angle), (float)Math.Sin(angle), (float)Math.Tan(zAngle));
}
I know this isn't right since the explosion isn't spherical... :(
Help?
Thank you!
-TS...
Formula for spherical explosion...
Your function pickDirection() must return a random direction with an equal probability of choosing one vector or another. The standard (and fastest) way of doing this is (I hope this correct C# code, as I code C++):
Emiel
float z = random(-1.0, 1.0);float f = Math.sqrt(1.0 - z * z);float azimuth = random(0.0, MathHelper.TwoPi);return new Vector3(Math.Cos(azimuth) * f, Math.Sin(azimuth) * f, z);
See this post (http://www.gamedev.net/community/forums/topic.asp?topic_id=499972&whichpage=1& #3261773) (a href weirdness: remove this space in this url) for more information (warning: C++).Emiel
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement