Exemplo n.º 1
0
        public virtual void UpdateBoundingBox()
        {
            var minX = float.MaxValue;
            var maxX = float.MinValue;
            var minY = float.MaxValue;
            var maxY = float.MinValue;

            foreach (var point in this.Geometry)
            {
                var x = this.Center.X + point.X;
                var y = this.Center.Y + point.Y;
                minX = Math.Min(x, minX);
                minY = Math.Min(x, minY);
                maxX = Math.Max(x, maxX);
                maxY = Math.Max(x, maxY);
            }

            BoundingBox = new Rect()
            {
                TopLeft = new Point() { X = minX, Y = minY },
                BottomRight = new Point() { X = maxX, Y = maxY }
            };
        }
Exemplo n.º 2
0
 public static Point NewPoint(this Random random, Rect bounds)
 {
     return new Point()
     {
         X = (float)random.NextDouble() * bounds.Width + bounds.TopLeft.X,
         Y = (float)random.NextDouble() * bounds.Height + bounds.TopLeft.Y
     };
 }
Exemplo n.º 3
0
 private bool IsOverlapping(Rect rect1, Rect rect2)
 {
     return !(rect2.TopLeft.X > rect1.BottomRight.X
              || rect2.BottomRight.X < rect1.TopLeft.X
              || rect2.TopLeft.Y > rect1.BottomRight.Y
              || rect2.BottomRight.Y < rect1.TopLeft.Y);
 }