jump-game/Jump Game/Library/PackageCache/com.unity.test-framework@1.0.13/UnityEngine.TestRunner/Utils/QuaternionEqualityComparer.cs
2020-01-29 10:05:38 +02:00

32 lines
931 B
C#

using System.Collections.Generic;
namespace UnityEngine.TestTools.Utils
{
public class QuaternionEqualityComparer : IEqualityComparer<Quaternion>
{
private const float k_DefaultError = 0.00001f;
private readonly float AllowedError;
private static readonly QuaternionEqualityComparer m_Instance = new QuaternionEqualityComparer();
public static QuaternionEqualityComparer Instance { get { return m_Instance; } }
private QuaternionEqualityComparer() : this(k_DefaultError) {}
public QuaternionEqualityComparer(float allowedError)
{
AllowedError = allowedError;
}
public bool Equals(Quaternion expected, Quaternion actual)
{
return Mathf.Abs(Quaternion.Dot(expected, actual)) > (1.0f - AllowedError);
}
public int GetHashCode(Quaternion quaternion)
{
return 0;
}
}
}