The class representing an axis-aligned bounding box (AABB) in 2D space.

Constructors

  • Create a 2d box bounded by min and max.

    Parameters

    • Optionalmin: AcGeVector2dLike

      (optional) Input 2d vector representing the lower (x, y) boundary of the box. Set it to ( + Infinity, + Infinity ) if undefined or null provided.

    • Optionalmax: AcGeVector2dLike

      (optional) Input 2d vector representing the upper (x, y) boundary of the box. Set it to ( - Infinity, - Infinity ) if undefined or null provided.

    Returns AcGeBox2d

Properties

The upper (x, y) boundary of the box

The lower (x, y) boundary of the box

Accessors

  • get center(): AcGeVector2d
  • Center point of this box

    Returns AcGeVector2d

  • get size(): AcGeVector2d
  • Return the width, height and depth of this box.

    Returns AcGeVector2d

Methods

  • Return a new 2d box with the same min and max as this one.

    Returns AcGeBox2d

    Return a new 2d box with the same min and max as this one.

  • Return true if this box includes the entirety of box. If this and box are identical, this function also returns true.

    Parameters

    • box: AcGeBox2d

      Input 2d box to test for inclusion.

    Returns boolean

    Return true if this box includes the entirety of box.

  • Return true if the specified point lies within or on the boundaries of this box.

    Parameters

    Returns boolean

    Return true if the specified point lies within or on the boundaries of this box.

  • Copy the min and max from box to this box.

    Parameters

    Returns this

    Return this box

  • Return the distance from any edge of this box to the specified point. If the point lies inside of this box, the distance will be 0.

    Parameters

    Returns number

    Return the distance from any edge of this box to the specified point.

  • Return true if this box and box share the same lower and upper bounds.

    Parameters

    • box: AcGeBox2d

      Input box to compare with this one.

    Returns boolean

    Return true if this box and box share the same lower and upper bounds.

  • Expand the boundaries of this box to include point.

    Parameters

    Returns this

    Return this box

  • Expand each dimension of the box by scalar. If negative, the dimensions of the box will be contracted.

    Parameters

    • scalar: number

      Input distance to expand the box by.

    Returns this

    Return this box

  • Expand this box equilaterally by vector. The width of this box will be expanded by the x component of vector in both directions. The height of this box will be expanded by the y component of vector in both directions.

    Parameters

    Returns this

    Return this box

  • Return the center point of the box as a 2d vector.

    Parameters

    • target: AcGeVector2d

      Input the result will be copied into this 2d vector.

    Returns AcGeVector2d

    Return the center point of the box as a 2d vector.

  • Return the width and height of this box.

    Parameters

    • target: AcGeVector2d

      Input the result will be copied into this 2d vector.

    Returns AcGeVector2d

    Return this box.

  • Return the intersection of this and box, setting the upper bound of this box to the lesser of the two boxes' upper bounds and the lower bound of this box to the greater of the two boxes' lower bounds.

    Parameters

    Returns this

    Return this box

  • Determine whether or not this box intersects box.

    Parameters

    • box: AcGeBox2d

      Input 2d box to check for intersection against.

    Returns boolean

    Return true if this box intersects box.

  • Return true if this box includes zero points within its bounds. Note that a box with equal lower and upper bounds still includes one point, the one both bounds share.

    Returns boolean

    Return true if this box includes zero points within its bounds.

  • Make this box empty.

    Returns this

    Return this box

  • Set the lower and upper (x, y) boundaries of this box. Please note that this method only copies the values from the given objects.

    Parameters

    • min: AcGeVector2dLike

      Input 2d vector representing the lower (x, y) boundary of the box.

    • max: AcGeVector2dLike

      Input 2d vector representing the upper (x, y) boundary of the box.

    Returns this

    Return this box

  • Center this box on center and set this box's width and height to the values specified in size.

    Parameters

    Returns this

    Return this box

  • Set the upper and lower bounds of this box to include all of the points in points.

    Parameters

    • points: AcGeVector2dLike[]

      Input one array of 2d vector that the resulting box will contain.

    Returns this

    Return this box

  • Add offset to both the upper and lower bounds of this box, effectively moving this box offset units in 2D space.

    Parameters

    Returns this

    Return this box

  • Union this box with box, setting the upper bound of this box to the greater of the two boxes' upper bounds and the lower bound of this box to the lesser of the two boxes' lower bounds.

    Parameters

    • box: AcGeBox2d

      Input the box that will be unioned with this box.

    Returns this

    Return this box