GlobalGameJame/Library/PackageCache/com.unity.test-framework@1.1.9/UnityEngine.TestRunner/Utils/QuaternionEqualityComparer.cs
JonatanRek bea2dce063 Initial
test
2020-01-31 16:10:04 +01: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;
}
}
}