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

Constructors

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

    Parameters

    • min: undefined | AcGeVector2dLike = undefined

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

    • max: undefined | AcGeVector2dLike = undefined

      (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

Methods

  • 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.

  • 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 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 AcGeBox2d

    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 AcGeBox2d

    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 AcGeBox2d

    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.

  • 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 AcGeBox2d

    Return this box