public static PointF[] GeneratePointCloud(Ellipse e, int numberOfPoints)
{
PointF[] cloud = new PointF[numberOfPoints];
GCHandle handle = GCHandle.Alloc(cloud, GCHandleType.Pinned);
using (Matrix<float> points = new Matrix<float>(numberOfPoints, 2, handle.AddrOfPinnedObject()))
using (Matrix<float> xValues = points.GetCol(0))
using (Matrix<float> yValues = points.GetCol(1))
using (RotationMatrix2D<float> rotation = new RotationMatrix2D<float>(e.MCvBox2D.center, e.MCvBox2D.angle, 1.0))
{
xValues.SetRandNormal(new MCvScalar(e.MCvBox2D.center.X), new MCvScalar(e.MCvBox2D.size.Width / 2.0f));
yValues.SetRandNormal(new MCvScalar(e.MCvBox2D.center.Y), new MCvScalar(e.MCvBox2D.size.Height / 2.0f));
rotation.RotatePoints(points);
}
handle.Free();
return cloud;
}