Example #1
0
        /// <summary>
        /// Returns true if the number is in the range that can be opened or closed(depends on the two signs)
        /// </summary>
        /// <param name = "number"> The number that will be controlled if it is in the range</param>
        /// <param name = "range"> The range</param>
        /// <param name = "firstSign">the lower limit of the range is inclusive or exclusive?</param>
        /// <param name = "secondSign">the upper limit of the range is inclusive or exclusive?</param>
        public static bool IsRange(float number, Range range, InequalitySign firstSign = InequalitySign.GraterOrEqual, InequalitySign secondSign = InequalitySign.GraterOrEqual)
        {
            Debug.Assert(range.Min <= range.Max);

            switch (firstSign)
            {
            case InequalitySign.GraterOrEqual:
                switch (secondSign)
                {
                case InequalitySign.GraterOrEqual:
                    return(number >= range.Min && number <= range.Max);

                case InequalitySign.Greater:
                    return(number >= range.Min && number < range.Max);
                }
                break;

            case InequalitySign.Greater:
                switch (secondSign)
                {
                case InequalitySign.GraterOrEqual:
                    return(number > range.Min && number <= range.Max);

                case InequalitySign.Greater:
                    return(number > range.Min && number < range.Max);
                }
                break;
            }
            return(false);
        }
Example #2
0
        /// <summary>
        /// Returns true if the number is in the range [0-max] that can be opened or closed(depends on the two signs)
        /// </summary>
        /// <param name = "number"> The number that will be controlled if it is in the range</param>
        /// <param name = "max"> The upper limit of the range</param>
        /// <param name = "firstSign">the lower limit of the range is inclusive or exclusive?</param>
        /// <param name = "secondSign">the upper limit of the range is inclusive or exclusive?</param>
        public static bool IsRange(float value, float max, InequalitySign firstSign = InequalitySign.GraterOrEqual, InequalitySign secondSign = InequalitySign.GraterOrEqual)
        {
            Debug.Assert(max > 0 && value >= 0 && value <= max);

            return(IsRange(value, new Range(0, max), firstSign, secondSign));
        }
Example #3
0
 /// <summary>
 /// Returns true if the number is in the range [0-1] that can be opened or closed(depends on the two signs)
 /// </summary>
 /// <param name = "number"> The number that will be controlled if it is in the range</param>
 /// <param name = "max"> The upper limit of the range</param>
 /// <param name = "firstSign">the lower limit of the range is inclusive or exclusive?</param>
 /// <param name = "secondSign">the upper limit of the range is inclusive or exclusive?</param>
 public static bool IsRange(float value, InequalitySign firstSign = InequalitySign.GraterOrEqual, InequalitySign secondSign = InequalitySign.GraterOrEqual)
 {
     return(IsRange(value, new Range(0, 1), firstSign, secondSign));
 }