Skip to content

Instantly share code, notes, and snippets.

@onedayitwillmake
Created April 6, 2011 04:30
Show Gist options
  • Save onedayitwillmake/905133 to your computer and use it in GitHub Desktop.
Save onedayitwillmake/905133 to your computer and use it in GitHub Desktop.
Uniformly distributed points on a sphere
float theta = M_PI * (3.0 - sqrtf(5.0));
float o = 2.0f / count;
float radius = 1500;
for(int i = 0; i < count; ++i)
{
float y = i * o - 1 + (o / 2);
float r = sqrtf(1 - y*y);
float phi = i * theta;
ci::Vec3f pos = ci::Vec3f( cosf(phi)*r, y, sinf(phi)*r) * radius;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment