Random point generator


#1

I would like to generate a Random point on the X-Y Plane within a boundary curve using RhinoCommon.

What is the best way to generate it without doing too many tests on whether the point is in the boundary?


(Menno Deij - van Rijswijk) #2

Depending on the shape of the boundary curve, you could determine its bounding box (i.e. rectangle) and put a random point inside the box (random widht/height). Then, test inside/outside with one of the Curve.Contains(...) methods. The curve must be closed of course.

http://4.rhino3d.com/5/rhinocommon/html/M_Rhino_Geometry_Curve_Contains.htm
http://4.rhino3d.com/5/rhinocommon/html/M_Rhino_Geometry_Curve_Contains_1.htm
http://4.rhino3d.com/5/rhinocommon/html/M_Rhino_Geometry_Curve_Contains_2.htm