Beispiel #1
0
        public static Vector3 RandomPosition(FloatBoundary b)
        {
            float x = R.Range(b.X.Min, b.X.Max);
            float y = R.Range(b.Y.Min, b.Y.Max);
            float z = 0;

            return(new Vector3(x, y, z));
        }
Beispiel #2
0
        public static List <Vector3> GenerateRandomPositions(int count, FloatBoundary boundary, float minDist = 1f, FloatBoundary exclude = new FloatBoundary())
        {
            List <Vector3> positions = new List <Vector3>();

            for (int i = 0; i < count; ++i)
            {
                var pos = RandomPosition(boundary);
                while (!CheckPosition(positions, pos, minDist) || exclude.IsInside(pos))
                {
                    pos = RandomPosition(boundary);
                }
                positions.Add(pos);
            }

            return(positions);
        }