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.
Static methods
staticfromRect(rect:Rectangle):AABB
Construct an AABB from an AS3 Rectangle object.
This method is only available on flash
and
openfl||nme
targets.
Parameters:
rect | The AS3 Rectangle to construct AABB from, this value must not be null. |
---|
Returns:
The constructed AABB matching the input Rectangle.
Throws:
# | If the input rectangle is null. |
---|
Constructor
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
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)
.
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)
.
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.