using UnityEngine;
using System.Collections;

namespace mgaia.Utils
{
    /// <summary>
    /// Extensões de float
    /// </summary>
    public static class FloatExtensions
    {
        private const float EPSILON = 1e-3f;

        public static bool Aproximate(this float num1, float num2, float precision = EPSILON)
        {
            return Mathf.Abs(num1 - num2) < precision;
        }
        
        public static int Compare(this float num1, float num2, float precision = EPSILON)
        {
            float diff = num1 - num2;
            return Mathf.Abs(diff) < precision ? 0 : (int)Mathf.Sign(diff);
        }

        public static bool Between(this float value, float lesser, float greater)
        {
            return Mathf.Abs(value * 2 - (greater + lesser)) < Mathf.Abs(greater - lesser);
        }
    }
}