AABB

    consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.

    It uses floating-point coordinates. The 2D counterpart to AABB is .

    Note: Unlike Rect2, AABB does not have a variant that uses integer coordinates.

    Tutorials

    Methods


    • position

    Beginning corner. Typically has values lower than end.


    Size from to end. Typically, all components are positive.

    If the size is negative, you can use to fix it.

    Method Descriptions

    Constructs an AABB from a position and size.


    Returns an AABB with equivalent position and size, modified so that the most-negative corner is the origin and the size is positive.


    • encloses ( AABB with )

    Returns true if this AABB completely encloses another one.


    Returns a copy of this AABB expanded to include a given point.

    Example:


    • get_area ( )

    Returns the volume of the AABB.


    Returns the center of the , which is equal to + (size / 2).


    • get_endpoint ( int idx )

    Gets the position of the 8 endpoints of the AABB in space.


    • get_longest_axis ( )

    Returns the normalized longest axis of the AABB.


    • int get_longest_axis_index ( )

    Returns the index of the longest axis of the AABB (according to ‘s AXIS_* constants).


    • float get_longest_axis_size ( )

    Returns the scalar length of the longest axis of the AABB.


    • get_shortest_axis ( )

    Returns the normalized shortest axis of the AABB.


    Returns the index of the shortest axis of the AABB (according to Vector3::AXIS* enum).


    • get_shortest_axis_size ( )

    Returns the scalar length of the shortest axis of the AABB.


    Returns the support point in a given direction. This is useful for collision detection algorithms.


    Returns a copy of the AABB grown a given amount of units towards all the sides.


    • bool has_no_area ( )

    Returns true if the AABB is flat or empty.


    • has_no_surface ( )

    Returns true if the AABB is empty.


    • bool has_point ( point )

    Returns true if the contains a point.


    • AABB intersection ( with )

    Returns the intersection between two AABB. An empty AABB (size 0,0,0) is returned on failure.


    • bool intersects ( with )

    Returns true if the AABB overlaps with another.


    • bool intersects_plane ( plane )

    Returns true if the AABB is on both sides of a plane.


    Returns true if the AABB intersects the line segment between from and to.


    • is_equal_approx ( AABB aabb )

    Returns true if this AABB and aabb are approximately equal, by calling on each component.


    Returns a larger AABB that contains both this AABB and .