inz-00/Assets/Scripts/PointDistribution/RandomDistribution.cs

24 lines
615 B
C#

using System;
using System.Collections.Generic;
using Assets.Common;
namespace Assets.PointDistribution
{
public class RandomDistribution : IPointDistribution
{
public readonly int N;
public readonly Random Random;
public RandomDistribution(int n, Random random)
{
Random = random ?? new Random();
N = n;
}
public IEnumerable<Point> Generate(double width, double height)
{
for (int x = 0; x < N; x++)
yield return new Point(Random.NextDouble() * width, Random.NextDouble());
}
}
}