public BoundingBox(BoundingBox box) { _minX = box._minX; _minY = box._minY; _maxX = box._maxX; _maxY = box._maxY; }
public void ZoomWindow(BoundingBox box) { var boxRatio = box.Width / box.Height; var clientRatio = (double)ClientSize.Width / ClientSize.Height; //var widthRatio = box.Width / ClientSize.Width; //var heightRatio = box.Height / ClientSize.Height; double zoom; if (boxRatio > clientRatio) zoom = ClientSize.Width / box.Width; else zoom = ClientSize.Height / box.Height; SetView(box.Center, zoom, 0, WindowChangedEventType.ZoomWindow); }
/// <summary> /// Returns the bounding box of the window. /// </summary> /// <returns>The bounding box of the window.</returns> public BoundingBox GetWindowBox() { var box = new BoundingBox(); box.Adjust(ClientToWorld(new Point(0, 0)).ToPoint2D()); box.Adjust(ClientToWorld(new Point(0, Height)).ToPoint2D()); box.Adjust(ClientToWorld(new Point(Width, 0)).ToPoint2D()); box.Adjust(ClientToWorld(new Point(Width, Height)).ToPoint2D()); return box; }
public bool Inside(BoundingBox box) { return _minX >= box._minX && _minY >= box._minY && _maxX <= box._maxX && _maxY <= box._maxY; }
/// <summary>Get the box that is the union with another bounding box,</summary> /// <param name="box">The bounding box.</param> public BoundingBox Union(BoundingBox box) { BoundingBox unionBox = new BoundingBox(this); unionBox.Adjust(box); return unionBox; }
/// <summary>Adjust the box to fit another bounding box,</summary> /// <param name="box">The bounding box.</param> public void Adjust(BoundingBox box) { if (box._minX < _minX) _minX = box._minX; if (box._minY < _minY) _minY = box._minY; if (box._maxX > _maxX) _maxX = box._maxX; if (box._maxY > _maxY) _maxY = box._maxY; }
public bool Intersect(BoundingBox box) { return !(box._minX >= _maxX || box._minY >= _maxY || box._maxX <= _minX || box._maxY <= _minY); }
/// <summary>Gets the intersection between 2 boxes.</summary> /// <param name="box">The 2nd bounding box.</param> /// <returns>The intersection. null if the dont intersect.</returns> public BoundingBox Intersection(BoundingBox box) { throw new Exception("Not coded yet!"); }
/// <summary>Sets the box by copying another one.</summary> /// <param name="box">The box to copy.</param> public void Set(BoundingBox box) { _minX = box._minX; _minY = box._minY; _maxX = box._maxX; _maxY = box._maxY; }
public bool Contains(BoundingBox box) { return box.Inside(this); }