Exemplo n.º 1
0
        public override bool Intersects(Tree.Rectangle rectangle)
        {
            var distanceX      = Mathf.Abs(PosX - rectangle.PosX);
            var distanceY      = Mathf.Abs(PosY - rectangle.PosY);
            var cornerDistance = Mathf.Pow(distanceX - rectangle.Width, 2) + Mathf.Pow(distanceY - rectangle.Height, 2);

            if (PosX < rectangle.PosX + rectangle.Width &&
                PosX > rectangle.PosX - rectangle.Width &&
                PosY < rectangle.PosY + rectangle.Height &&
                PosY > rectangle.PosY - rectangle.Height)   //inside the rectangle
            {
                return(true);
            }

            if (distanceX > Radius + rectangle.Width || distanceY > Radius + rectangle.Height)
            {
                return(false);
            }

            if (distanceX <= Radius + rectangle.Width)
            {
                return(true);
            }

            if (distanceY <= Radius + rectangle.Height)
            {
                return(true);
            }

            return(cornerDistance <= Mathf.Pow(Radius, 2));
        }
Exemplo n.º 2
0
        public void ShapeSetType()
        {
            //ACT
            Shape rectangle = new Tree.Rectangle();

            //ASSERT
            Assert.AreEqual(rectangle.GetShapeType(), ShapeType.RECTANGLE);
        }
Exemplo n.º 3
0
 public override bool Intersects(Tree.Rectangle rectangle)
 {
     return(!(
                PosX + Width < rectangle.PosX - rectangle.Width ||
                PosX - Width > rectangle.PosX + rectangle.Width ||
                PosY - Height > rectangle.PosY + rectangle.Height ||
                PosY + Height < rectangle.PosY - rectangle.Height
                ));
 }
Exemplo n.º 4
0
 private void mutate(OperationType operationType, Rectangle[] rects)
 {
     var operation = new Operation(OperationType.Add);
     operation.Rects = rects;
     lock (operation.Sync)
     {
         this.queue.Enqueue(operation);
         Monitor.Wait(operation.Sync);
     }
 }
Exemplo n.º 5
0
        public void ShapeSetGetColor()
        {
            //ACT
            Shape rectangleRed = new Tree.Rectangle();

            rectangleRed.Color = Color.Red;

            //ASSERT
            Assert.AreEqual(rectangleRed.Color, Color.Red);
        }
Exemplo n.º 6
0
 public ICollection<Rectangle> Query(Rectangle rect)
 {
     return null;
 }
Exemplo n.º 7
0
 public abstract bool Intersects(Tree.Rectangle rectangle);