I recently came across a formula that has proven to be quite useful for my project. The code I'm referring to can be found at this link: (specifically the sphere version).
Although I made some modifications to adapt the code to my own objects, the underlying math remains unchanged.
My main query revolves around understanding the calculation behind the positioning in the code snippet provided below:
for ( var i = 0, l = 30; i < l; i ++ ) {
var phi = Math.acos( -1 + ( 2 * i ) / l );
var theta = Math.sqrt( l * Math.PI ) * phi;
var object = new THREE.Mesh( geometry, material );
object.position.x = 1000 * Math.cos( theta ) * Math.sin( phi );
object.position.y = 1000 * Math.sin( theta ) * Math.sin( phi );
object.position.z = 1000 * Math.cos( phi );
scene.add(object);
}
If anyone could shed light on the intricacies of this calculation, I would greatly appreciate it.
Your assistance is truly valued. Thank you.