Class: AABB
physics/aabb/aabb.AABB
Represents an axis aligned bounding box in 2D world space.
A minimum (bottom left) and maximum (top right) vertex is used to represent the AABB.
Constructors
constructor
โข new AABB(min
, max
)
Creates a AABB with the given minimum and and maximum vertices.
Parameters
Name | Type | Description |
---|---|---|
min | vec2 | The minimum vertex (bottom left) |
max | vec2 | The maximum vertex (top right) |
Defined in
src/physics/aabb/aabb.ts:29
โข new AABB(a
, b
, margin
)
Creates an AABB which contains both a
and b
, the created AABB is the union of a
and b
plus the margin
.
Parameters
Name | Type | Description |
---|---|---|
a | AABB | An AABB |
b | AABB | An AABB |
margin | number | A margin to add to the min and max of the created AABB |
Defined in
src/physics/aabb/aabb.ts:38
โข new AABB(obj
, margin
)
Creates a AABB that bounds the vertices of the given object's collider.
Parameters
Name | Type | Description |
---|---|---|
obj | CollisionObject | CollisionObject to create AABB from |
margin | number | A margin to add to the new min and max points |
Defined in
src/physics/aabb/aabb.ts:46
Properties
margin
โข margin: number
Defined in
src/physics/aabb/aabb.ts:16
max
โข max: vec2
Defined in
src/physics/aabb/aabb.ts:14
min
โข min: vec2
Defined in
src/physics/aabb/aabb.ts:13
obj
โข obj: CollisionObject
A CollisionObject that is bound by the AABB.
Defined in
src/physics/aabb/aabb.ts:21
Methods
area
โธ area(): number
Computes the area of the AABB.
Returns
number
The area of the AABB
Defined in
src/physics/aabb/aabb.ts:119
clipLine
โธ Private
clipLine(dim
, v0
, v1
, fLow
, fHigh
): false
| { fHigh
: number
= newFHigh; fLow
: number
= newFLow }
Clips a line based on the AABB's min and max to determine if the line intersects with the AABB.
Parameters
Name | Type | Description |
---|---|---|
dim | number | The dimension to clip in (0 = x, 1 = y) |
v0 | vec2 | The line's start point |
v1 | vec2 | The line's end point |
fLow | number | The current fLow |
fHigh | number | The current fHigh |
Returns
false
| { fHigh
: number
= newFHigh; fLow
: number
= newFLow }
false when no intersection possible, otherwise new fLow and fHigh
Defined in
src/physics/aabb/aabb.ts:196
contains
โธ contains(b
): boolean
Determines wether or not the given AABB is contained within this AABB.
Parameters
Name | Type | Description |
---|---|---|
b | AABB | The AABB to check |
Returns
boolean
Defined in
src/physics/aabb/aabb.ts:182
intersects
โธ intersects(b
): boolean
Determines wether or not this AABB intersects with the given AABB.
Parameters
Name | Type | Description |
---|---|---|
b | AABB | The AABB to check for intersection against |
Returns
boolean
Defined in
src/physics/aabb/aabb.ts:131
โธ intersects(point
): boolean
Determines wether or not the given point intersects with this AABB.
Parameters
Name | Type | Description |
---|---|---|
point | vec2 | The point to check for intersection |
Returns
boolean
Defined in
src/physics/aabb/aabb.ts:138
โธ intersects(ray
): boolean
Determines wether or not the given ray intersects with this AABB.
Parameters
Name | Type | Description |
---|---|---|
ray | Ray | The ray to check for intersection |
Returns
boolean
Defined in
src/physics/aabb/aabb.ts:145
setMinMaxFromCollisionObj
โธ setMinMaxFromCollisionObj(obj
, margin
): void
Sets the AABB's min and max so that the AABB contains the object's collider.
Parameters
Name | Type | Description |
---|---|---|
obj | CollisionObject | The CollisionObject to bound |
margin | number | A margin to add to the new min and max points |
Returns
void
Defined in
src/physics/aabb/aabb.ts:65
union
โธ union(a
, b
, margin?
): void
Sets the AABB's min and max to the union of a
and b
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
a | AABB | undefined | An AABB |
b | AABB | undefined | An AABB |
margin | number | 0 | A margin to add to the new min and max points |
Returns
void
Defined in
src/physics/aabb/aabb.ts:103