HitResult

public class HitResult

Defines an intersection between a ray and estimated real-world geometry.

Protected Constructors

HitResult()
(FOR TESTING) Constructs a new instance for use as a mock.

Public Methods

Anchor
createAnchor()
Creates a new anchor at the hit location.
boolean
equals(Object obj)
Indicates whether some other object is a HitResult referencing the same logical hit result as this one.
float
getDistance()
Returns the distance from the camera to the hit location, in meters.
Pose
getHitPose()
Returns the pose of the intersection between a ray and detected real-world geometry.
Trackable
getTrackable()
Returns the Trackable that was hit.
int
hashCode()
Returns a hash code value for the object.

Inherited Methods

Protected Constructors

protected HitResult ()

(FOR TESTING) Constructs a new instance for use as a mock. Calling any base method implementation on this instance (including even equals(Object) and hashCode()) may return unexpected results, throw an exception, or even crash.

To obtain a HitResult normally, use hitTest(float, float).

Public Methods

public Anchor createAnchor ()

Creates a new anchor at the hit location. See getHitPose() for details.

hitResult.createAnchor() is a convenience alias for hitResult.getTrackable().createAnchor(hitResult.getHitPose())

public boolean equals (Object obj)

Indicates whether some other object is a HitResult referencing the same logical hit result as this one.

Parameters
obj the reference object with which to compare.
Returns
  • true if this object is the same as the obj argument; false otherwise.

public float getDistance ()

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

public Pose getHitPose ()

Returns the pose of the intersection between a ray and detected real-world geometry. The position is the location in space where the ray intersected the geometry. The orientation is a best effort to face the user's device, and its exact definition differs depending on the Trackable that was hit.

Plane: X+ is perpendicular to the cast ray and parallel to the plane, Y+ points along the plane normal (up, for HORIZONTAL_UPWARD_FACING planes), and Z+ is parallel to the plane, pointing roughly toward the user's device.

Point: Attempt to estimate the normal of the surface centered around the hit test. Surface normal estimation is most likely to succeed on textured surfaces and with camera motion. If getOrientationMode() returns ESTIMATED_SURFACE_NORMAL, then X+ is perpendicular to the cast ray and parallel to the physical surface centered around the hit test, Y+ points along the estimated surface normal, and Z+ points roughly toward the user's device. If getOrientationMode() returns INITIALIZED_TO_IDENTITY, then X+ is perpendicular to the cast ray and points right from the perspective of the user's device, Y+ points up, and Z+ points roughly toward the user's device.

If you wish to retain the location of this pose beyond the duration of a single frame, create an Anchor using createAnchor() to save the pose in a physically consistent way.

See Also

public Trackable getTrackable ()

Returns the Trackable that was hit.

public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

Returns
  • a hash code value for this object.
See Also

Send feedback about...