Emgu.CV.PointCollection.GeneratePointCloud C# (CSharp) Method

GeneratePointCloud() public static method

Generate a random point cloud around the ellipse.
public static GeneratePointCloud ( Ellipse e, int numberOfPoints ) : System.Drawing.PointF[]
e Emgu.CV.Structure.Ellipse The region where the point cloud will be generated. The axes of e corresponds to std of the random point cloud.
numberOfPoints int The number of points to be generated
return System.Drawing.PointF[]
        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;
        }