void Generate()
        {
            var lowerBound = new Vector2(-8.0f, -8.0f);
            var upperBound = new Vector2(8.0f, 8.0f);

            for (var i = 0; i < Count; ++i)
            {
                var x = 10.0f * RandomFloat();
                var y = 10.0f * RandomFloat();

                // Clamp onto a square to help create collinearities.
                // This will stress the convex hull algorithm.
                var v = new Vector2(x, y);
                v          = Vector2.Clamp(v, lowerBound, upperBound);
                _points[i] = v;
            }

            _count = Count;
        }
Esempio n. 2
0
        private void MoveAABB(ref AABB aabb)
        {
            Vector2 d;

            d.X = RandomFloat(-0.5f, 0.5f);
            d.Y = RandomFloat(-0.5f, 0.5f);

            //d.X = 2.0f;
            //d.Y = 0.0f;
            aabb.LowerBound += d;
            aabb.UpperBound += d;

            var c0  = 0.5f * (aabb.LowerBound + aabb.UpperBound);
            var min = new Vector2();

            min.Set(-_worldExtent, 0.0f);
            var max = new Vector2();

            max.Set(_worldExtent, 2.0f * _worldExtent);
            var c = Vector2.Clamp(c0, min, max);

            aabb.LowerBound += c - c0;
            aabb.UpperBound += c - c0;
        }