private Point3d [ ] generateSpherePoints ( int nSpherePoints ) { Point3d [ ] points = new Point3d [ nSpherePoints ] ; double inc = Math . PI * ( 3.0 - Math . sqrt ( 5.0 ) ) ; double offset = 2.0 / nSpherePoints ; for ( int k = 0 ; k < nSpherePoints ; k ++ ) { double y = k * offset - 1.0 + ( offset / 2.0 ) ; double r = Math . sqrt ( 1.0 - y * y ) ; double phi = k * inc ; points [ k ] = new Point3d ( Math . cos ( phi ) * r , y , Math . sin ( phi ) * r ) ; } return points ; }
Returns list of 3d coordinates of points on a sphere using the Golden Section Spiral algorithm .