Recently, I delved into the world of Three.js, eager to experiment with its capabilities. My project involved creating an ellipsoid cloud of particles using the PointCloud object.
To achieve this, I employed the parametric equation of an ellipsoid to generate random points:
var vertex = new THREE.Vector3();
u = Math.random() * 2 * Math.PI;
v = Math.random() * Math.PI;
vertex.x = Math.random() * a * Math.cos(u) * Math.sin(v);
vertex.y = Math.random() * b * Math.sin(u) * Math.sin(v);
vertex.z = Math.random() * c * Math.cos(v);
Upon rendering the cloud, I noticed an unusual concentration of particles along the ellipsoid's axes. Could this be attributed to the distribution of the Math.random() function or am I overlooking something? Any insights would be greatly appreciated.
You can view the project here, and I have provided a screenshot for reference in case the visualization varies on your browser.
Edit: Following @severin-pappadeux's suggestion, I refined the code to address the uneven point distribution issue, but unfortunately, the problem persists.
Edit: In an attempt to rectify the issue, I adjusted the formula that utilizes Math.random() to define the vertices' length from:
vertex.x = Math.random() * a * wx;
vertex.y = Math.random() * b * wy;
vertex.z = Math.random() * c * wz;
to:
vertex.x = (Math.random() + 0.1) * a * wx;
vertex.y = (Math.random() + 0.1) * b * wy;
vertex.z = (Math.random() + 0.1) * c * wz;
The particles exhibited a more uniform distribution with this adjustment. Interestingly, there was no formation of a "cross-like hole" where the axes intersect, contrary to my initial expectations. While this tweak resolved my immediate concern, I remain curious about a more robust solution.