예제 #1
0
        public AffineTransform(Box from_box, Box to_box)
        {
            _matrix = new double[6] { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 };

            Translate(-from_box.X1, -from_box.Y1);
            Scale(to_box.Width / from_box.Width, to_box.Height / from_box.Height);
            Translate(to_box.X1, to_box.X1);
        }
예제 #2
0
 public bool Intersects(Box rhs)
 {
     return ((rhs._x1 <= _x1 && _x1 <= rhs._x2) || (_x1 <= rhs._x1 && rhs._x1 <= _x2)) &&
            ((rhs._y1 <= _y1 && _y1 <= rhs._y2) || (_y1 <= rhs._y1 && rhs._y1 <= _y2));
 }
예제 #3
0
 public void ExpandToInclude(Box rhs)
 {
     _x1 = Math.Min(_x1, rhs._x1);
     _y1 = Math.Min(_y1, rhs._y1);
     _x2 = Math.Max(_x2, rhs._x2);
     _y2 = Math.Max(_y2, rhs._y2);
 }
예제 #4
0
        public double GetOverlappingArea(Box rhs)
        {
            double rightMostLeft = Math.Max(_x1, rhs._x1);
            double leftMostRight = Math.Min(_x2, rhs._x2);

            double bottomMostTop = Math.Max(_y1, rhs._y1);
            double topMostBottom = Math.Min(_y2, rhs._y2);

            if (leftMostRight <= rightMostLeft) return 0.0;
            if (topMostBottom <= bottomMostTop) return 0.0;

            return (leftMostRight - rightMostLeft) * (topMostBottom - bottomMostTop);
        }
예제 #5
0
 public bool Contains(Box rhs)
 {
     return
         _x1 <= rhs._x1 && rhs._x1 <= _x2 &&
         _x1 <= rhs._x2 && rhs._x2 <= _x2 &&
         _y1 <= rhs._y1 && rhs._y1 <= _y2 &&
         _y1 <= rhs._y2 && rhs._y2 <= _y2;
 }