# HitResult

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

*** ** * ** ***


```
public final class HitResult
```

<br />

*** ** * ** ***

Intersection between a ray and estimated real-world geometry.

Can be obtained from `https://developer.android.com/reference/androidx/xr/arcore/package-summary#hitTest(androidx.xr.runtime.Session,androidx.xr.runtime.math.Ray)`. If the ray intersects a `https://developer.android.com/reference/androidx/xr/arcore/Plane` that is being subsumed, the subsuming `https://developer.android.com/reference/androidx/xr/arcore/Plane` will be returned.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/xr/arcore/Anchorable#createAnchor(androidx.xr.runtime.math.Pose)` |   |

## Summary

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/xr/arcore/HitResult#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final float` | `https://developer.android.com/reference/androidx/xr/arcore/HitResult#getDistance()()` the distance from the camera to the hit location, in meters |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose` | `https://developer.android.com/reference/androidx/xr/arcore/HitResult#getHitPose()()` the `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` of the intersection between a ray and the `https://developer.android.com/reference/androidx/xr/arcore/Trackable` in the world coordinate space |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/Trackable<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/Trackable.State>` | `https://developer.android.com/reference/androidx/xr/arcore/HitResult#getTrackable()()` the `https://developer.android.com/reference/androidx/xr/arcore/Trackable` that was hit |
| `int` | `https://developer.android.com/reference/androidx/xr/arcore/HitResult#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/arcore/HitResult#toString()()` Returns a string representation of `https://developer.android.com/reference/androidx/xr/arcore/HitResult` for debugging. |

## Public methods

### equals

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

### getDistance

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

```
public final float getDistance()
```

the distance from the camera to the hit location, in meters

### getHitPose

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

```
public final @NonNull Pose getHitPose()
```

the `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` of the intersection between a ray and the `https://developer.android.com/reference/androidx/xr/arcore/Trackable` in the world coordinate space

If the hit `https://developer.android.com/reference/androidx/xr/arcore/Trackable` is a `https://developer.android.com/reference/androidx/xr/arcore/Plane`, the hitPose will be parallel to the `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` of the `https://developer.android.com/reference/androidx/xr/arcore/Plane`.

The hit `https://developer.android.com/reference/androidx/xr/arcore/Trackable` may also be an instance of `https://developer.android.com/reference/androidx/xr/arcore/Anchorable`. If so, an anchor representing the hit position can be created from the `https://developer.android.com/reference/androidx/xr/arcore/Anchorable`

### getTrackable

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

```
public final @NonNull Trackable<@NonNull Trackable.State> getTrackable()
```

the `https://developer.android.com/reference/androidx/xr/arcore/Trackable` that was hit

### hashCode

```
public int hashCode()
```

### toString

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

Returns a string representation of `https://developer.android.com/reference/androidx/xr/arcore/HitResult` for debugging.

Note: Not intended for production use.