Class: AABB
Defines an Axis-Aligned Bounding Box
Hierarchy
- AABB
Index
Constructors
Properties
Methods
- _calculateAABB
- _calculateAABBFromArrayPoints
- _getCenter
- _resetCache
- addPoint
- clone
- contains
- distanceToPoint
- expandSidesUniformly
- getCenter
- getCenterReference
- getDepth
- getDimensions
- getDimensionsReference
- getHeight
- getIntersection
- getMax
- getMin
- getPoints
- getPoints2D
- getSurfaceArea
- getVolume
- getWidth
- getXmax
- getXmin
- getYmax
- getYmin
- getZmax
- getZmin
- isEmpty
- isSimilarTo
- overlaps
- setFromArrayPoints
- setFromPoints
- toString
- toSvg
- translate
- combineAABBs
- fromVectorPolygons3D
Constructors
constructor
+ new AABB(points?: readonly ReadonlyVector3[]): AABB
Defined in src/util/AABB.ts:34
Defines an AABB based on the given points
Parameters:
| Name | Type |
|---|---|
points? |
readonly ReadonlyVector3[] |
Returns: AABB
Properties
Private cachedCenter
• cachedCenter: Vector3 | null = null
Defined in src/util/AABB.ts:34
Private cachedVolume
• cachedVolume: number | null = null
Defined in src/util/AABB.ts:33
Private dimensions
• dimensions: Vector3 | null = null
Defined in src/util/AABB.ts:31
Private max
• max: Vector3 | null = null
Defined in src/util/AABB.ts:30
Private min
• min: Vector3 | null = null
Defined in src/util/AABB.ts:29
Methods
Private _calculateAABB
▸ _calculateAABB(points: readonly ReadonlyVector3[]): void
Defined in src/util/AABB.ts:369
Calculates the bounding box values
Parameters:
| Name | Type |
|---|---|
points |
readonly ReadonlyVector3[] |
Returns: void
Private _calculateAABBFromArrayPoints
▸ _calculateAABBFromArrayPoints(points: readonly ArrayPoint2[] | readonly ArrayPoint3[]): void
Defined in src/util/AABB.ts:337
Parameters:
| Name | Type |
|---|---|
points |
readonly ArrayPoint2[] | readonly ArrayPoint3[] |
Returns: void
Private _getCenter
▸ _getCenter(): Vector3‹›
Defined in src/util/AABB.ts:330
Returns: Vector3‹›
Private _resetCache
▸ _resetCache(): void
Defined in src/util/AABB.ts:386
Returns: void
addPoint
▸ addPoint(point: Vector3): void
Defined in src/util/AABB.ts:268
Parameters:
| Name | Type |
|---|---|
point |
Vector3 |
Returns: void
clone
▸ clone(): AABB
Defined in src/util/AABB.ts:312
Returns: AABB
contains
▸ contains(point: Vector3, tolerance: number): boolean
Defined in src/util/AABB.ts:169
Determines whether a point is within the bounding box
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
point |
Vector3 | - | Point to test |
tolerance |
number | 0 | Tolerance that is added to the borders |
Returns: boolean
distanceToPoint
▸ distanceToPoint(point: ReadonlyVector3): number
Defined in src/util/AABB.ts:285
Parameters:
| Name | Type |
|---|---|
point |
ReadonlyVector3 |
Returns: number
expandSidesUniformly
▸ expandSidesUniformly(expansion: number): void
Defined in src/util/AABB.ts:297
Expands the AABB by adding the specified value to each side (so e.g. width will have 2 * expansion added)
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
expansion |
number | 0.05 | (optional) Delta by which each side should be expanded, in mm, defaults to 0.05 |
Returns: void
getCenter
▸ getCenter(): Vector3
Defined in src/util/AABB.ts:139
Returns: Vector3
Center of the AABB, as a new vector instance
getCenterReference
▸ getCenterReference(): ReadonlyVector3
Defined in src/util/AABB.ts:146
Returns: ReadonlyVector3
Center of the AABB, as a reference to the cached center (which must not be changed!)
getDepth
▸ getDepth(): number
Defined in src/util/AABB.ts:117
Returns: number
Depth of the AABB in Y direction
getDimensions
▸ getDimensions(): Vector3
Defined in src/util/AABB.ts:96
Returns: Vector3
Dimensions of the AABB, as a new vector instance
getDimensionsReference
▸ getDimensionsReference(): ReadonlyVector3
Defined in src/util/AABB.ts:103
Returns: ReadonlyVector3
Dimensions of the AABB, as a reference (which must not be changed!)
getHeight
▸ getHeight(): number
Defined in src/util/AABB.ts:124
Returns: number
Height of the AABB in Z direction
getIntersection
▸ getIntersection(otherAABB: AABB): AABB | null
Defined in src/util/AABB.ts:205
Return the AABB where this and otherAABB intersect. Null if there is no overlap. Note that you may get a zero volume AABB.
Parameters:
| Name | Type | Description |
|---|---|---|
otherAABB |
AABB | AABB to intersect with |
Returns: AABB | null
The intersection AABB or null if there was no intersection
getMax
▸ getMax(): Vector3
Defined in src/util/AABB.ts:132
Returns: Vector3
getMin
▸ getMin(): Vector3
Defined in src/util/AABB.ts:128
Returns: Vector3
getPoints
▸ getPoints(): Vector3[]
Defined in src/util/AABB.ts:228
Returns: Vector3[]
getPoints2D
▸ getPoints2D(): Vector3[]
Defined in src/util/AABB.ts:244
Returns: Vector3[]
Points of the 2D-part of the AABB (x and y)
getSurfaceArea
▸ getSurfaceArea(): number
Defined in src/util/AABB.ts:157
Returns: number
getVolume
▸ getVolume(): number
Defined in src/util/AABB.ts:150
Returns: number
getWidth
▸ getWidth(): number
Defined in src/util/AABB.ts:110
Returns: number
Width of the AABB in X direction
getXmax
▸ getXmax(): number
Defined in src/util/AABB.ts:73
Returns: number
getXmin
▸ getXmin(): number
Defined in src/util/AABB.ts:69
Returns: number
getYmax
▸ getYmax(): number
Defined in src/util/AABB.ts:81
Returns: number
getYmin
▸ getYmin(): number
Defined in src/util/AABB.ts:77
Returns: number
getZmax
▸ getZmax(): number
Defined in src/util/AABB.ts:89
Returns: number
getZmin
▸ getZmin(): number
Defined in src/util/AABB.ts:85
Returns: number
isEmpty
▸ isEmpty(): boolean
Defined in src/util/AABB.ts:45
Returns: boolean
isSimilarTo
▸ isSimilarTo(otherAABB: AABB, epsilon: number): boolean
Defined in src/util/AABB.ts:260
Determines whether this AABB is similar (same center + dimensions) to another AABB within a given epsilon distance value
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
otherAABB |
AABB | - | Other AABB to compare to |
epsilon |
number | 0.1 | Epsilon distance value that is used for comparison |
Returns: boolean
True, if both AABBs are similar, false, if not
overlaps
▸ overlaps(otherAABB: AABB, epsilon: number): boolean
Defined in src/util/AABB.ts:187
Calculates whether AABB overlaps with otherAABB
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
otherAABB |
AABB | - | - |
epsilon |
number | 0 | Distance that is added to the aabb to allow side-on-side aabbs to overlap |
Returns: boolean
setFromArrayPoints
▸ setFromArrayPoints(points: readonly ArrayPoint2[] | readonly ArrayPoint3[]): this
Defined in src/util/AABB.ts:63
Use when your points have ArrayPoint2 or ArrayPoint3 type. (Avoid mapping it to Vector3s (which is slow and a lot of GC) and use it directly.)
Parameters:
| Name | Type | Description |
|---|---|---|
points |
readonly ArrayPoint2[] | readonly ArrayPoint3[] | - |
Returns: this
setFromPoints
▸ setFromPoints(points: readonly ReadonlyVector3[]): void
Defined in src/util/AABB.ts:53
Use when your points have Vector3 type.
Parameters:
| Name | Type | Description |
|---|---|---|
points |
readonly ReadonlyVector3[] | - |
Returns: void
toString
▸ toString(): string
Defined in src/util/AABB.ts:326
Returns: string
toSvg
▸ toSvg(): string
Defined in src/util/AABB.ts:316
Returns: string
translate
▸ translate(vector: Vector3): void
Defined in src/util/AABB.ts:280
Parameters:
| Name | Type |
|---|---|
vector |
Vector3 |
Returns: void
Static combineAABBs
▸ combineAABBs(...aabbs: readonly AABB[]): AABB
Defined in src/util/AABB.ts:18
Returns a new (possibly empty) AABB enclosing all input AABBs.
Parameters:
| Name | Type | Description |
|---|---|---|
...aabbs |
readonly AABB[] | - |
Returns: AABB
Static fromVectorPolygons3D
▸ fromVectorPolygons3D(polygons: ReadonlyVectorPolygon3D[]): AABB
Defined in src/util/AABB.ts:9
Parameters:
| Name | Type |
|---|---|
polygons |
ReadonlyVectorPolygon3D[] |
Returns: AABB