# BoundingBox

Artifact: [androidx.xr.runtime:runtime](https://developer.android.com/jetpack/androidx/releases/xr-runtime) [View Source](https://cs.android.com/search?q=file:androidx/xr/runtime/math/BoundingBox.kt+class:androidx.xr.runtime.math.BoundingBox) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-runtime#1.0.0)

*** ** * ** ***


```
class BoundingBox
```

<br />

*** ** * ** ***

Axis-aligned bounding box in 3D space, defined by minimum and maximum corners.

## Summary

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox#fromCenterAndHalfExtents(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.FloatSize3d)(center: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, halfExtents: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/FloatSize3d)` Creates a `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox` from a center point and its half-extents. |
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox#fromMinMax(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)(min: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3, max: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3)` Creates a `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox` with the given minimum and maximum corner points. |

| ### Public functions |
|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox#hashCode()()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox#toString()()` |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox#center()` the center point of the box |
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/FloatSize3d` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox#halfExtents()` the distance from the center to each face of the box along the axes. |
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox#max()` a `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` representing the maximum corner of the box (highest x, y, and z values) |
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` | `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox#min()` a `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` representing the minimum corner of the box (lowest x, y, and z values) |

## Public companion functions

### fromCenterAndHalfExtents

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-runtime#1.0.0)

```
fun fromCenterAndHalfExtents(center: Vector3, halfExtents: FloatSize3d): BoundingBox
```

Creates a `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox` from a center point and its half-extents.

This factory method ensures that the created bounding box is valid by checking that all components of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox.Companion#fromCenterAndHalfExtents(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.FloatSize3d)` and `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox.Companion#fromCenterAndHalfExtents(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.FloatSize3d)` are not `NaN`, and that each component of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox.Companion#fromCenterAndHalfExtents(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.FloatSize3d)` is greater than or equal to zero.

| Parameters |
|---|---|
| `center: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` | the center point of the box. Its components must not be `NaN` |
| `halfExtents: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/FloatSize3d` | the distance from the center to each face of the box. Its components must not be `NaN` and must be greater than or equal to zero |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox` | a new `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox` instance |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if any component of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox.Companion#fromCenterAndHalfExtents(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.FloatSize3d)` or `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox.Companion#fromCenterAndHalfExtents(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.FloatSize3d)` is `NaN`, or if any component of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox.Companion#fromCenterAndHalfExtents(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.FloatSize3d)` is negative |

### fromMinMax

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-runtime#1.0.0)

```
fun fromMinMax(min: Vector3, max: Vector3): BoundingBox
```

Creates a `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox` with the given minimum and maximum corner points.

This factory method ensures that the created bounding box is valid by checking that all components of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox.Companion#fromMinMax(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)` and `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox.Companion#fromMinMax(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)` are not `NaN`, and that each component of the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox.Companion#fromMinMax(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)` point is less than or equal to the corresponding component of the `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox.Companion#fromMinMax(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)` point.

| Parameters |
|---|---|
| `min: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` | a `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` representing the minimum corner of the box (lowest x, y, and z values). Its components must not be `NaN` |
| `max: https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` | a `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` representing the maximum corner of the box (highest x, y, and z values). Its components must not be `NaN` |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox` | a new `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox` instance |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if any component of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox.Companion#fromMinMax(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)` or `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox.Companion#fromMinMax(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)` is `NaN`, or if any component of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox.Companion#fromMinMax(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)` is greater than the corresponding component of `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/BoundingBox.Companion#fromMinMax(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)` |

## Public functions

### equals

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

```
open fun hashCode(): Int
```

### toString

```
open fun toString(): String
```

## Public properties

### center

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-runtime#1.0.0)

```
val center: Vector3
```

the center point of the box

### halfExtents

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-runtime#1.0.0)

```
val halfExtents: FloatSize3d
```

the distance from the center to each face of the box along the axes. The total width, height, and depth of the box are twice the half-extent values

### max

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-runtime#1.0.0)

```
val max: Vector3
```

a `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` representing the maximum corner of the box (highest x, y, and z values)

### min

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-runtime#1.0.0)

```
val min: Vector3
```

a `https://developer.android.com/reference/kotlin/androidx/xr/runtime/math/Vector3` representing the minimum corner of the box (lowest x, y, and z values)