Exemplo n.º 1
0
        public IBoundingBox <T> GetCoveredBoundingbox(IBoundingBox <T> otherBoundingBox)
        {
            if (otherBoundingBox is BoundingBox2D <T> )
            {
                var other2DBoundingBox = (BoundingBox2D <T>)otherBoundingBox;

                var coveredBb = (BoundingBox2D <T>) this.Clone();

                if (this.X.CompareTo(other2DBoundingBox.X) > 0)
                {
                    coveredBb.X = other2DBoundingBox.X;
                }

                if (this.Y.CompareTo(other2DBoundingBox.Y) > 0)
                {
                    coveredBb.Y = other2DBoundingBox.Y;
                }

                if (this.Right.CompareTo(other2DBoundingBox.Right) < 0)
                {
                    coveredBb.Width = BoundingBoxHelper <T> .Add(this.Width,
                                                                 BoundingBoxHelper <T> .Substract(other2DBoundingBox.Right, this.Right));
                }

                if (this.Bottom.CompareTo(other2DBoundingBox.Bottom) < 0)
                {
                    coveredBb.Height = BoundingBoxHelper <T> .Add(this.Height,
                                                                  BoundingBoxHelper <T> .Substract(other2DBoundingBox.Bottom, this.Bottom));
                }

                return(coveredBb);
            }
            else
            {
                throw new ApplicationException(@"not adequat dimension");
            }
        }
Exemplo n.º 2
0
 public T GetArea()
 {
     return(BoundingBoxHelper <T> .Multi(this.Width, this.Height));
 }