# 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)

*** ** * ** ***


```
public final class BoundingBox
```

<br />

*** ** * ** ***

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

## Summary

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox` | `https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox#fromCenterAndHalfExtents(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.FloatSize3d)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 center, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d halfExtents )` Creates a `https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox` from a center point and its half-extents. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox` | `https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox#fromMinMax(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 min, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 max)` Creates a `https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox` with the given minimum and maximum corner points. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` | `https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox#getCenter()()` the center point of the box |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d` | `https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox#getHalfExtents()()` the distance from the center to each face of the box along the axes. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` | `https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox#getMax()()` a `https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` representing the maximum corner of the box (highest x, y, and z values) |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` | `https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox#getMin()()` a `https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` representing the minimum corner of the box (lowest x, y, and z values) |
| `int` | `https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox#hashCode()()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox#toString()()` |

## Public methods

### equals

```
public boolean equals(Object other)
```

### fromCenterAndHalfExtents

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

```
public static final @NonNull BoundingBox fromCenterAndHalfExtents(
    @NonNull Vector3 center,
    @NonNull FloatSize3d halfExtents
)
```

Creates a `https://developer.android.com/reference/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/androidx/xr/runtime/math/BoundingBox.Companion#fromCenterAndHalfExtents(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.FloatSize3d)` and `https://developer.android.com/reference/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/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 center` | the center point of the box. Its components must not be `NaN` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d halfExtents` | 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/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox` | a new `https://developer.android.com/reference/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/androidx/xr/runtime/math/BoundingBox.Companion#fromCenterAndHalfExtents(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.FloatSize3d)` or `https://developer.android.com/reference/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/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)

```
public static final @NonNull BoundingBox fromMinMax(@NonNull Vector3 min, @NonNull Vector3 max)
```

Creates a `https://developer.android.com/reference/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/androidx/xr/runtime/math/BoundingBox.Companion#fromMinMax(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)` and `https://developer.android.com/reference/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/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/androidx/xr/runtime/math/BoundingBox.Companion#fromMinMax(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)` point.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 min` | a `https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` representing the minimum corner of the box (lowest x, y, and z values). Its components must not be `NaN` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 max` | a `https://developer.android.com/reference/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/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/BoundingBox` | a new `https://developer.android.com/reference/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/androidx/xr/runtime/math/BoundingBox.Companion#fromMinMax(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)` or `https://developer.android.com/reference/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/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/androidx/xr/runtime/math/BoundingBox.Companion#fromMinMax(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)` |

### getCenter

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

```
public final @NonNull Vector3 getCenter()
```

the center point of the box

### getHalfExtents

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

```
public final @NonNull FloatSize3d getHalfExtents()
```

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

### getMax

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

```
public final @NonNull Vector3 getMax()
```

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

### getMin

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

```
public final @NonNull Vector3 getMin()
```

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

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```