Skip to content

Instantly share code, notes, and snippets.

@cwhitney
Created October 22, 2013 17:14
Show Gist options
  • Save cwhitney/7104466 to your computer and use it in GitHub Desktop.
Save cwhitney/7104466 to your computer and use it in GitHub Desktop.
// I was getting bad results, so I looked up uniform sphere distribution and got this: http://mathworld.wolfram.com/SpherePointPicking.html
float phi = ofRandom( 0, TWO_PI );
float costheta = ofRandom( -1.0f, 1.0f );
float rho = sqrt( 1.0f - costheta * costheta );
float x = rho * cos( phi );
float y = rho * sin( phi );
float z = costheta;
ofVec3f randVec(x, y, z);
ofVec3f pos = randVec * ofRandom( 100.0f, 600.0f );
ofVec3f vel = -randVec;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment