# Equals

> Performs exact binary comparison of each Quaternion component (x, y, z, w).

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## Equals(Object)

Performs exact binary comparison of each Quaternion component (x, y, z, w).

```csharp
public override readonly bool Equals(object other)
```

### Parameters

**** (\[Object]\(https\://learn.microsoft.com/dotnet/api/system.object)): The quaternion to compare with.

### Returns

| Type                                                          | Description                                                         |
| ------------------------------------------------------------- | ------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the quaternion components (x, y, z, w) are exactly equal. |

### Remarks

The key comparison characteristics:

* Exact copies: Returns `true` when quaternions are identical copies.
* Floating-point precision: Returns `false` even for tiny differences due to floating-point arithmetic.
* Mathematically equivalent rotations: Returns `false` for rotations that represent the same orientation but have different component values.

For practical rotation comparison, consider using the `==` operator instead, which uses dot product with tolerance for approximate equality.

### Examples

```csharp
using UnityEngine;

public class QuaternionEqualsExample : MonoBehaviour
{ 
    void Start()
    {
        // Exact copies - Equals() returns true
        Quaternion q1 = Quaternion.identity;
        Quaternion q2 = q1;
        Debug.Log($"Exact copies - Equals(): {q1.Equals(q2)}"); // True

        // Small floating point differences - Equals() returns false
        Quaternion q3 = Quaternion.Euler(90f, 0f, 0f);
        Quaternion q4 = Quaternion.Euler(90.0001f, 0f, 0f);
        Debug.Log($"Small difference - Equals(): {q3.Equals(q4)}"); // False
        Debug.Log($"Small difference - == operator: {q3 == q4}");   // True (tolerance-based)

        // Combine both methods for robust comparison
        Debug.Log($"Combined check: {q3.Equals(q4) || (q3 == q4)}"); // True
    }
}
```

## Equals(Quaternion)

Performs exact binary comparison of each Quaternion component (x, y, z, w).

```csharp
public readonly bool Equals(Quaternion other)
```

### Parameters

**** (\[Quaternion]\(/engine/6000.7/script-reference/unityengine/quaternion)): The quaternion to compare with.

### Returns

| Type                                                          | Description                                                         |
| ------------------------------------------------------------- | ------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the quaternion components (x, y, z, w) are exactly equal. |

### Remarks

The key comparison characteristics:

* Exact copies: Returns `true` when quaternions are identical copies.
* Floating-point precision: Returns `false` even for tiny differences due to floating-point arithmetic.
* Mathematically equivalent rotations: Returns `false` for rotations that represent the same orientation but have different component values.

For practical rotation comparison, consider using the `==` operator instead, which uses dot product with tolerance for approximate equality.

### Examples

```csharp
using UnityEngine;

public class QuaternionEqualsExample : MonoBehaviour
{ 
    void Start()
    {
        // Exact copies - Equals() returns true
        Quaternion q1 = Quaternion.identity;
        Quaternion q2 = q1;
        Debug.Log($"Exact copies - Equals(): {q1.Equals(q2)}"); // True

        // Small floating point differences - Equals() returns false
        Quaternion q3 = Quaternion.Euler(90f, 0f, 0f);
        Quaternion q4 = Quaternion.Euler(90.0001f, 0f, 0f);
        Debug.Log($"Small difference - Equals(): {q3.Equals(q4)}"); // False
        Debug.Log($"Small difference - == operator: {q3 == q4}");   // True (tolerance-based)

        // Combine both methods for robust comparison
        Debug.Log($"Combined check: {q3.Equals(q4) || (q3 == q4)}"); // True
    }
}
```

## Equals(Quaternion)

Performs exact binary comparison of each Quaternion component (x, y, z, w).

```csharp
public readonly bool Equals(in Quaternion other)
```

### Parameters

**** (\[Quaternion]\(/engine/6000.7/script-reference/unityengine/quaternion)): The quaternion to compare with.

### Returns

| Type                                                          | Description                                                         |
| ------------------------------------------------------------- | ------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the quaternion components (x, y, z, w) are exactly equal. |

### Remarks

The key comparison characteristics:

* Exact copies: Returns `true` when quaternions are identical copies.
* Floating-point precision: Returns `false` even for tiny differences due to floating-point arithmetic.
* Mathematically equivalent rotations: Returns `false` for rotations that represent the same orientation but have different component values.

For practical rotation comparison, consider using the `==` operator instead, which uses dot product with tolerance for approximate equality.

### Examples

```csharp
using UnityEngine;

public class QuaternionEqualsExample : MonoBehaviour
{ 
    void Start()
    {
        // Exact copies - Equals() returns true
        Quaternion q1 = Quaternion.identity;
        Quaternion q2 = q1;
        Debug.Log($"Exact copies - Equals(): {q1.Equals(q2)}"); // True

        // Small floating point differences - Equals() returns false
        Quaternion q3 = Quaternion.Euler(90f, 0f, 0f);
        Quaternion q4 = Quaternion.Euler(90.0001f, 0f, 0f);
        Debug.Log($"Small difference - Equals(): {q3.Equals(q4)}"); // False
        Debug.Log($"Small difference - == operator: {q3 == q4}");   // True (tolerance-based)

        // Combine both methods for robust comparison
        Debug.Log($"Combined check: {q3.Equals(q4) || (q3 == q4)}"); // True
    }
}
```
