I'm trying to figure out what is going on in next example
https://threejs.org/examples/css3d_periodictable.html (the sphere version)
var vector = new THREE.Vector3();
var spherical = new THREE.Spherical();
for ( var i = 0, l = objects.length; i < l; i ++ ) {
var phi = Math.acos( -1 + ( 2 * i ) / l );
var theta = Math.sqrt( l * Math.PI ) * phi;
var object = new THREE.Object3D();
spherical.set( 800, phi, theta );
object.position.setFromSpherical( spherical );
...
}
I read some math articles (there were just explanations of converting spherical coordinates to Cartesian) and found this question Can someone explain the formula. It was impossible for me to leave a comment there due to my reputation, however after all of that I still don't understand how did they get these two formulas.
var phi = Math.acos( -1 + ( 2 * i ) / l );
var theta = Math.sqrt( l * Math.PI ) * phi;
So my questions are:
1) How do you get these formulas?
2) Why was the length of objects used to get phi and theta?