Last active
May 14, 2016 01:38
-
-
Save tado/8ad5884056ae92956164642c09d511dd to your computer and use it in GitHub Desktop.
random location within a sphere
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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