using UnityEngine;
namespace FirstGearGames.Utilities.Maths
{
public static class Quaternions
{
///
/// Returns if a rotational value matches another. This method is preferred over Equals or == since those variations allow larger differences before returning false.
///
///
///
///
///
public static bool Matches(this Quaternion r, Quaternion target, float? distance = null)
{
if (distance == null)
{
return (r.w == target.w && r.x == target.x && r.y == target.y && r.z == target.z);
}
else
{
float a = Vector3.SqrMagnitude(r.eulerAngles - target.eulerAngles);
return (a <= (distance * distance));
}
}
}
}