Axis Aligned Bounding Box (AABB)

Note that in many cases of an AABB object being returned by a Nape function the AABB object will be marked internally as an 'immutable' AABB. This will always be documented and trying to mutate such an AABB will result in an error being thrown.

Constructor

@:value({ height : 0, width : 0, y : 0, x : 0 })new(x:Float = 0, y:Float = 0, width:Float = 0, height:Float = 0)

Construct a new AABB.

As input width/height are permitted to be negative it is not guaranteed that the resultant AABB will have the same parameters as those specified as the AABB parameters are guaranteed to always have positive width/height, and for x/y to always be the top-left corner.

Parameters:

x

The x coordinate of the top-left corner of the AABB. (default 0)

y

The y coordinate of the top-left corner of the AABB (default 0)

width

The width of the AABB. This value may be negative. (default 0)

height

The height of the AABB. This value may be negative. (default 0)

Returns:

The newly constructed AABB object.

Variables

@:value(null)zpp_inner:ZPP_AABB = null

@private

min:Vec2

The minimum bounds for the AABB.

Euivalent to the top-left corner.
This Vec2 is intrinsically linked to the AABB so that modifications to this object are reflected in changes to the AABB and vice-versa.

If the AABB is immutable, then this Vec2 will also be immutable.

This value can be set with the = operator, equivalent to performing aabb.min.set(value).

max:Vec2

The maximum bounds for the AABB.

Euivalent to the bottom-right corner.
This Vec2 is intrinsically linked to the AABB so that modifications to this object are reflected in changes to the AABB and vice-versa.

If the AABB is immutable, then this Vec2 will also be immutable.

This value can be set with the = operator, equivalent to performing aabb.max.set(value).

x:Float

The x coordinate of the AABB's top-left corner.

Equivalent to accessing/mutating min.x.

y:Float

The y coordinate of the AABB's top-left corner.

Equivalent to accessing/mutating min.y.

width:Float

width of AABB.

This value is and must always be positive.

height:Float

height of AABB.

This value is and must always be positive.

Methods

copy():AABB

Produce a copy of this AABB.

As would be expected, if you produce a copy of an 'immutable' AABB then the copy will be 'mutable'.

Returns:

The copy of this AABB.

@:keeptoString():String

@private