Random points loop

unhandled

(Amir Habibi) #1

Hi , what is the best way to loop a set of random double for creating a list of point inside a bounding box ?
I’ve showed the way for creating one single point

Random random = new Random();
Point3d pt = new Point3d(0, 0, 0);

//creating boundingbox around ur mesh for random point generation
BoundingBox bb = mesh.GetBoundingBox(true);
//finding the corners
Point3d[] corners = bb.GetCorners();
//get the random pt
pt.X = corners[0].X + (corners[1].X - corners[0].X) * random.NextDouble();
pt.Y = corners[0].Y + (corners[3].Y - corners[0].Y) * random.NextDouble();
pt.Z = corners[0].Z + (corners[4].Z - corners[0].Z) * random.NextDouble();
A = pt;

#2
Random rnd = new Random();
Box bb = new Box(mesh.GetBoundingBox(true));
Point3d[] pts = new Point3d[PointCount];
for(int i=0; i<PointCount; i++){
   pts[i] = bb.PointAt(rnd.NextDouble(), rnd.NextDouble(), rnd.NextDouble());
}
A = pts;

(Amir Habibi) #3

That’s the whole story
Thanks Dani