Beispiel #1
0
        /// <summary>
        /// Returns true if this rectangle is wholely within the bounds of the other object
        /// </summary>
        public bool IsWithin(ISpatial2D spatial)
        {
            if (spatial is Rectangle)
            {
                var other = (Rectangle)spatial;

                return(TopLeft.X >= other.TopLeft.X &&
                       TopLeft.Y >= other.TopLeft.X &&
                       BottomRight.X <= other.BottomRight.X &&
                       BottomRight.Y <= other.BottomRight.Y);
            }

            return(!(Positions.Except(spatial.Positions).Any()));
        }
Beispiel #2
0
 /// <summary>
 /// Returns true if this rectangle overlaps the other object
 /// </summary>
 public bool Overlaps(ISpatial2D spatial)
 {
     return(spatial.Positions.Any(p => Overlaps(p)));
 }
Beispiel #3
0
 public ObjectOutOfBoundsException(ISpatial2D spacialObject)
 {
     Object = spacialObject;
 }
Beispiel #4
0
 public RuleViolationEvent(ISpatialRule rule, ISpatial2D target)
 {
     Rule   = rule;
     Target = target;
 }
Beispiel #5
0
        /// <summary>
        /// Returns true if this object is wholely within the bounds of the other object
        /// </summary>
        public bool IsWithin(ISpatial2D spatial)
        {
            //TODO: Could be optimised for simple shapes?

            return(Positions.All(p => spatial.Overlaps(p)));
        }
Beispiel #6
0
 public bool Overlaps(ISpatial2D spatial)
 {
     return(Overlaps(spatial.Positions));
 }