showing results for - "javascript random point on unit sphere"
Agustina
05 Jun 2017
1function randomSpherePoint(x0,y0,z0,radius){
2   var u = Math.random();
3   var v = Math.random();
4   var theta = 2 * Math.PI * u;
5   var phi = Math.acos(2 * v - 1);
6   var x = x0 + (radius * Math.sin(phi) * Math.cos(theta));
7   var y = y0 + (radius * Math.sin(phi) * Math.sin(theta));
8   var z = z0 + (radius * Math.cos(phi));
9   return [x,y,z];
10}