Beispiel #1
0
    public List <Point> GeneratePoints(int amount, double maxX, double maxY, GenerationType generationType)
    {
        MaxX = maxX;
        MaxY = maxY;

        var point0 = new Point(0, 0);
        var point1 = new Point(0, MaxY);
        var point2 = new Point(MaxX, MaxY);
        var point3 = new Point(MaxX, 0);

        var points = new List <Point>(amount + 1)
        {
            point0, point1, point2, point3
        };

        tri1 = new Triangle(point0, point1, point2);
        tri2 = new Triangle(point0, point2, point3);

        border = new List <Triangle>()
        {
            tri1, tri2
        };

        var random = new System.Random();

        switch (generationType)
        {
        case GenerationType.Guassian:
            for (int i = 0; i < amount - 4; i++)
            {
                var pointXG = Math.Abs(random.NextGaussian(0, 0.3f) * MaxX);
                var pointYG = Math.Abs(random.NextGaussian(0, 0.3f) * MaxY);

                points.Add(new Point(pointXG, pointYG));
            }

            break;

        case GenerationType.Random:
            for (int i = 0; i < amount - 4; i++)
            {
                var pointX = random.NextDouble() * MaxX;
                var pointY = random.NextDouble() * MaxY;
                points.Add(new Point(pointX, pointY));
            }

            break;

        case GenerationType.Circle:
            for (int i = 0; i < amount - 4; i++)
            {
                var point = random.InCircleGetPoint(1500);
                points.Add(point);
            }

            break;

        default:
            throw new ArgumentOutOfRangeException(nameof(generationType), generationType, null);
        }

        return(points);
    }