namespace Zinnia.Extension
{
using UnityEngine;
///
/// Extended methods for the Type.
///
public static class FloatExtensions
{
///
/// Determines if two values are equal based on a given tolerance.
///
/// The to compare against.
/// The to compare with.
/// The tolerance in which the two values can be within to be considered equal.
/// if the two values are considered equal.
public static bool ApproxEquals(this float a, float b, float tolerance = float.Epsilon)
{
float difference = Mathf.Abs(tolerance);
return (Mathf.Abs(a - b) <= difference);
}
///
/// Converts the given degree angle from a full unsigned 0' to 360' range into the signed -180' to 180' equivalent.
///
/// The unsigned degree to convert.
/// The converted signed degree.
public static float GetSignedDegree(this float degree)
{
return (degree > 180f) ? degree - 360f : degree;
}
}
}