Skip to content

Instantly share code, notes, and snippets.

@tado
Last active May 14, 2016 01:38
Show Gist options
  • Save tado/8ad5884056ae92956164642c09d511dd to your computer and use it in GitHub Desktop.
Save tado/8ad5884056ae92956164642c09d511dd to your computer and use it in GitHub Desktop.
random location within a sphere
float theta = 2.0 * PI * ofRandom(1.0);
float phi = acos(2.0 * ofRandom(1.0) - 1.0);
float x = radius * sin(phi) * cos(theta);
float y = radius * sin(phi) * sin(theta);
float z = radius * cos(phi);
ofVec3f location = ofVec3f(x, y, z);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment