# Anchor

`
public class
Anchor
` Describes a fixed location and orientation in the real world. To stay at a fixed location in
physical space, the numerical description of this position will update as ARCore's understanding
of the space improves.

Use `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor#getPose()` to get the current numerical location of this anchor. This location may
change any time `https://developers.google.com/ar/reference/java/com/google/ar/core/Session#update()` is called, but will never spontaneously change.

mathematically:  

`point_world = anchor.getPose().transformPoint(point_local);`  

`point_world = anchor.getPose().toMatrix() * point_local;`

`anchor.getPose().toMatrix(...)` provides a matrix appropriate for composing with the
view and projection matrices when rendering an object at this anchor's location.

`Anchor`s are hashable and may for example be used as keys in `HashMap`s.

Anchors incur ongoing processing overhead within ARCore. To release unneeded anchors use
`https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor#detach()`.

## Nested Classes

|---|---|---|---|
| ` enum ` | `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor.CloudAnchorState` || Result of a Cloud Anchor hosting or resolving operation. |
| ` enum ` | `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor.RooftopAnchorState` || Describes the Rooftop anchor state of asynchronous operation launched by `https://developers.google.com/ar/reference/java/com/google/ar/core/Earth#resolveAnchorOnRooftopAsync(double,%20double,%20double,%20float,%20float,%20float,%20float,%20java.util.function.BiConsumer<com.google.ar.core.Anchor,%20com.google.ar.core.Anchor.RooftopAnchorState>)`. |
| ` enum ` | `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor.TerrainAnchorState` || Describes the result of a Terrain anchor operation. |

## Public Methods

|---|---|
| ` void ` | `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor#detach()()` Detaches this Anchor from its Trackable removes it from the Session. |
| ` boolean ` | `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)` Indicates whether some other object is an `Anchor` referencing the same logical anchor as this one. |
| ` https://developer.android.com/reference/java/lang/String ` | `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor#getCloudAnchorId()()` *This method is deprecated. For cloud anchors hosted by the async method `https://developers.google.com/ar/reference/java/com/google/ar/core/Session#hostCloudAnchorAsync(com.google.ar.core.Anchor,%20int,%20java.util.function.BiConsumer<java.lang.String,%20com.google.ar.core.Anchor.CloudAnchorState>)`, the result Cloud Anchor ID can be obtained from the corresponding callback or Future object. This method will always return the empty string for anchors created through async methods.* |
| ` https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor.CloudAnchorState ` | `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor#getCloudAnchorState()()` *This method is deprecated. For Cloud Anchor operations created by the async Cloud Anchor methods, the result state can be obtained from the corresponding callback or `https://developers.google.com/ar/reference/java/com/google/ar/core/Future` object. This method will always return `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor.CloudAnchorState#NONE` for anchors created through async methods.* |
| ` https://developers.google.com/ar/reference/java/com/google/ar/core/Pose ` | `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor#getPose()()` Returns the pose of the anchor in the world coordinate space. |
| ` https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor.TerrainAnchorState ` | `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor#getTerrainAnchorState()()` *This method is deprecated. For resolve operations created by the async method `https://developers.google.com/ar/reference/java/com/google/ar/core/Earth#resolveAnchorOnTerrainAsync(double,%20double,%20double,%20float,%20float,%20float,%20float,%20java.util.function.BiConsumer<com.google.ar.core.Anchor,%20com.google.ar.core.Anchor.TerrainAnchorState>)`, the result state can be obtained for the callback or future object.* |
| ` https://developers.google.com/ar/reference/java/com/google/ar/core/TrackingState ` | `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor#getTrackingState()()` Returns the current state of the pose of this anchor. |
| ` int ` | `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor#hashCode()()` Returns a hash code value for the object. |

## Inherited Methods

From `class
java.lang.Object`

|---|---|
| ` https://developer.android.com/reference/java/lang/Object ` | `clone()` |
| ` boolean ` | `equals(https://developer.android.com/reference/java/lang/Object arg0)` |
| ` void ` | `finalize()` |
| ` final https://developer.android.com/reference/java/lang/Class<?> ` | `getClass()` |
| ` int ` | `hashCode()` |
| ` final void ` | `notify()` |
| ` final void ` | `notifyAll()` |
| ` https://developer.android.com/reference/java/lang/String ` | `toString()` |
| ` final void ` | `wait(long arg0, int arg1)` |
| ` final void ` | `wait(long arg0)` |
| ` final void ` | `wait()` |

## Public Methods

#### public
void
detach
()

### detach

```java
public void detach()
```
Detaches this Anchor from its Trackable removes it from the Session. After calling,
getTrackingState() will return `https://developers.google.com/ar/reference/java/com/google/ar/core/TrackingState#STOPPED` and ARCore will
no longer update this Anchor's pose or return it from `https://developers.google.com/ar/reference/java/com/google/ar/core/Session#getAllAnchors()`.

#### public
boolean
equals
([Object](https://developer.android.com/reference/java/lang/Object) obj)

### equals

```java
public boolean equals(
  Object obj
)
```
Indicates whether some other object is an `Anchor` referencing the same logical anchor as
this one.

| Details ||
| Parameters | |---|---| | `obj` | the reference object with which to compare. | |
| Returns | `true` if this object is the same as the obj argument; `false` otherwise. |
| See Also | - `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor#hashCode()` - `https://developer.android.com/reference/java/util/HashMap` |
|---|---|

#### public
[String](https://developer.android.com/reference/java/lang/String)
getCloudAnchorId
()

### getCloudAnchorId

```java
public String getCloudAnchorId()
```


**This method was deprecated** .  
For cloud anchors hosted by the async method `https://developers.google.com/ar/reference/java/com/google/ar/core/Session#hostCloudAnchorAsync(com.google.ar.core.Anchor,%20int,%20java.util.function.BiConsumer<java.lang.String,%20com.google.ar.core.Anchor.CloudAnchorState>)`, the result Cloud Anchor ID can be
obtained from the corresponding callback or Future object. This method will always return
the empty string for anchors created through async methods.
Gets the current cloud anchor ID for this anchor. Returns an empty string if `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor#getCloudAnchorState()` returns `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor.CloudAnchorState#TASK_IN_PROGRESS` or
`https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor.CloudAnchorState#NONE`.

#### public
[Anchor.CloudAnchorState](https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor.CloudAnchorState)
getCloudAnchorState
()

### getCloudAnchorState

```java
public Anchor.CloudAnchorState getCloudAnchorState()
```


**This method was deprecated** .  
For Cloud Anchor operations created by the async Cloud Anchor methods, the result
state can be obtained from the corresponding callback or `https://developers.google.com/ar/reference/java/com/google/ar/core/Future` object. This method
will always return `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor.CloudAnchorState#NONE` for anchors created through async methods.
Gets the current Cloud Anchor state of this anchor.

#### public
[Pose](https://developers.google.com/ar/reference/java/com/google/ar/core/Pose)
getPose
()

### getPose

```java
public Pose getPose()
```
Returns the pose of the anchor in the world coordinate space. This pose may change each time
`https://developers.google.com/ar/reference/java/com/google/ar/core/Session#update()` is called. This pose should only be used for rendering if `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor#getTrackingState()` returns `https://developers.google.com/ar/reference/java/com/google/ar/core/TrackingState#TRACKING`.

#### public
[Anchor.TerrainAnchorState](https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor.TerrainAnchorState)
getTerrainAnchorState
()

### getTerrainAnchorState

```java
public Anchor.TerrainAnchorState getTerrainAnchorState()
```


**This method was deprecated** .  
For resolve operations created by the async method `https://developers.google.com/ar/reference/java/com/google/ar/core/Earth#resolveAnchorOnTerrainAsync(double,%20double,%20double,%20float,%20float,%20float,%20float,%20java.util.function.BiConsumer<com.google.ar.core.Anchor,%20com.google.ar.core.Anchor.TerrainAnchorState>)`, the result state can be obtained for the callback or future object.
Gets the current Terrain anchor state of this anchor. This state is guaranteed not to change
until `https://developers.google.com/ar/reference/java/com/google/ar/core/Session#update()` is called. For Anchors that are not Terrain anchors, this function
returns `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor.TerrainAnchorState#NONE`. See `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor.TerrainAnchorState` for the possible
Terrain anchor states.

#### public
[TrackingState](https://developers.google.com/ar/reference/java/com/google/ar/core/TrackingState)
getTrackingState
()

### getTrackingState

```java
public TrackingState getTrackingState()
```
Returns the current state of the pose of this anchor. If this state is anything other than
`https://developers.google.com/ar/reference/java/com/google/ar/core/TrackingState#TRACKING` the pose should not be considered useful.

Note: Starting in ARCore 1.12, changing the active camera config using `https://developers.google.com/ar/reference/java/com/google/ar/core/Session#setCameraConfig(com.google.ar.core.CameraConfig)` may cause the tracking state on certain devices to
become permanently PAUSED. For consistent behavior across all supported devices, release any
previously created anchors when setting a new camera config.

#### public
int
hashCode
()

### hashCode

```java
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 `https://developer.android.com/reference/java/util/HashMap`.

| Details ||
| Returns | a hash code value for this object. |
| See Also | - `https://developers.google.com/ar/reference/java/com/google/ar/core/Anchor#equals(java.lang.Object)` |
|---|---|