Class Box2D

java.lang.Object
com.irurueta.geometry.Box<Point2D>
com.irurueta.geometry.Box2D
All Implemented Interfaces:
Serializable

public class Box2D extends Box<Point2D>
This class defines a 2D rectangular area aligned with the horizontal and vertical axes. A box is defined by two corners, low, containing minimum coordinate values, and high, containing maximum coordinate values. This class is used internally by KD trees and quad trees.
See Also:
  • Constructor Details

    • Box2D

      public Box2D()
      Empty constructor. Creates a box centered at the origin and having unitary area.
    • Box2D

      public Box2D(Point2D lo, Point2D hi)
      Constructor.
      Parameters:
      lo - low coordinate values.
      hi - high coordinate values.
    • Box2D

      public Box2D(Rectangle rectangle)
      Constructor from rectangle.
      Parameters:
      rectangle - a rectangle.
  • Method Details

    • setBounds

      public final void setBounds(double loX, double loY, double hiX, double hiY)
      Sets boundaries.
      Parameters:
      loX - horizontal low coordinate.
      loY - vertical low coordinate.
      hiX - horizontal high coordinate.
      hiY - vertical high coordinate.
    • fromRectangle

      public final void fromRectangle(Rectangle rectangle)
      Sets values of this box from provided rectangle.
      Parameters:
      rectangle - a rectangle containing boundaries.
    • toRectangle

      public Rectangle toRectangle()
      Creates a rectangle equivalent to this box.
      Returns:
      a rectangle equivalent to this box.
    • toRectangle

      public void toRectangle(Rectangle result)
      Sets values into provided rectangle to make it equivalent to this box.
      Parameters:
      result - instance where values will be stored.