Fix Quaternion comparison epsilon to reduce error rate
This commit is contained in:
@@ -635,7 +635,7 @@ namespace FlaxEngine
|
||||
public static float AngleBetween(Quaternion a, Quaternion b)
|
||||
{
|
||||
float num = Dot(a, b);
|
||||
return num > 0.99999999f ? 0 : Mathf.Acos(Mathf.Min(Mathf.Abs(num), 1f)) * 2f * 57.29578f;
|
||||
return num > 0.9999999f ? 0 : Mathf.Acos(Mathf.Min(Mathf.Abs(num), 1f)) * 2f * 57.29578f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1478,7 +1478,7 @@ namespace FlaxEngine
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator ==(Quaternion left, Quaternion right)
|
||||
{
|
||||
return Dot(ref left, ref right) > 0.99999999f;
|
||||
return Dot(ref left, ref right) > 0.9999999f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1493,7 +1493,7 @@ namespace FlaxEngine
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool operator !=(Quaternion left, Quaternion right)
|
||||
{
|
||||
return Dot(ref left, ref right) <= 0.99999999f;
|
||||
return Dot(ref left, ref right) <= 0.9999999f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1605,7 +1605,7 @@ namespace FlaxEngine
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool Equals(ref Quaternion other)
|
||||
{
|
||||
//return Dot(ref this, ref other) > 0.99999999f;
|
||||
//return Dot(ref this, ref other) > 0.9999999f;
|
||||
return Mathf.NearEqual(other.X, X) && Mathf.NearEqual(other.Y, Y) && Mathf.NearEqual(other.Z, Z) && Mathf.NearEqual(other.W, W);
|
||||
}
|
||||
|
||||
|
||||
@@ -391,7 +391,7 @@ public:
|
||||
/// <returns><c>true</c> if the specified <see cref="Quaternion" /> is equal to this instance; otherwise, <c>false</c>.</returns>
|
||||
FORCE_INLINE bool operator==(const Quaternion& other) const
|
||||
{
|
||||
return Dot(*this, other) > 0.99999999f;
|
||||
return Dot(*this, other) > 0.9999999f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -414,7 +414,7 @@ public:
|
||||
/// <returns><c>true</c> if the specified <see cref="Quaternion" /> structures are equal; otherwise, <c>false</c>.</returns>
|
||||
static bool NearEqual(const Quaternion& a, const Quaternion& b)
|
||||
{
|
||||
return Dot(a, b) > 0.99999999f;
|
||||
return Dot(a, b) > 0.9999999f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -474,7 +474,7 @@ public:
|
||||
static float AngleBetween(const Quaternion& a, const Quaternion& b)
|
||||
{
|
||||
const float dot = Dot(a, b);
|
||||
return dot > 0.99999999f ? 0 : Math::Acos(Math::Min(Math::Abs(dot), 1.0f)) * 2.0f * 57.29578f;
|
||||
return dot > 0.9999999f ? 0 : Math::Acos(Math::Min(Math::Abs(dot), 1.0f)) * 2.0f * 57.29578f;
|
||||
}
|
||||
|
||||
// Adds two quaternions
|
||||
|
||||
Reference in New Issue
Block a user