javascript - Repartition of points in an ellipsoid PointCloud with Three.js -
i have started experiment three.js. tried create ellipsoid cloud of particles using pointcloud object.
i generate random points using parametric equation of ellipsoid so:
var vertex = new three.vector3(); u = math.random() * 2 * math.pi; v = math.random() * math.pi; vertex.x = math.random() * * 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);
but when render cloud, notice unusual amount of particles agglomerate around ellipsoid's axes.
i wondering if linked distribution of math.random() function or missing ? please me understand this.
you can have @ here , made screenshot in case doesn't same on browser.
edit: code modified kindly suggested @severin-pappadeux in order avoid incorrectly distributed points, problem remains.
edit: modified part use math.random() set length of vertices, was:
vertex.x = math.random() * * wx; vertex.y = math.random() * b * wy; vertex.z = math.random() * c * wz;
to:
vertex.x = (math.random() + 0.1) * * wx; vertex.y = (math.random() + 0.1) * b * wy; vertex.z = (math.random() + 0.1) * c * wz;
and particles more evenly distributed. more intriguing doesn't form "cross-like hole" axes are, expect since math.random() + 0.1 not yield value below 0.1. little trick kind of solved problem, though still interested in answer.
you want create cloud of random points uniformly distributed inside 3d ellipsoid.
first, generate random point inside cube, , ignore points outside embedded sphere.
vertex.x = 2 * math.random() - 1; vertex.y = 2 * math.random() - 1; vertex.z = 2 * math.random() - 1; if ( vertex.length() < 1 ) geometry.vertices.push( vertex );
you have uniform points inside sphere. create ellipsoid, scale point cloud after create it.
var pointcloud = new three.points( geometry, material ); pointcloud.scale.set( a, b, c );
three.js r.86
Comments
Post a Comment