For example, if I have 20 points evenly distributed on the sphere, how should I calculate

topic description

in the process of learning three.js, I saw the process of using three.js to draw a sphere, in which the key part, given a certain number of points, evenly distributed on a sphere, his code is as follows, but does not understand the details

            // sphere

            var vector = new THREE.Vector3();
            var spherical = new THREE.Spherical();

            for ( var i = 0, l = objects.length; i < l; i PP ) {

                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 );

                vector.copy( object.position ).multiplyScalar( 2 );

                object.lookAt( vector );

                targets.sphere.push( object );

            }
            
    

here we are looking for phi and theta . I don"t understand how it is calculated. How does it work out?

original address

Apr.03,2021
Menu