예제 #1
0
        public static void BoxRangeInsideAnother(ref long min, ref long max, long outerMin, long outerMax)
        {
            RangeHelper.Normalize(ref min, ref max);
            RangeHelper.Normalize(ref outerMin, ref outerMax);
            long num1 = max - min;
            long num2 = outerMax - outerMin;

            if (num1 > num2)
            {
                min = outerMin;
                max = outerMax;
            }
            else if (min < outerMin)
            {
                min = outerMin;
                max = outerMin + num1;
            }
            else
            {
                if (max <= outerMax)
                {
                    return;
                }
                max = outerMax;
                min = outerMax - num1;
            }
        }
예제 #2
0
        public static void BoxRangeInsideAnother(ref double min, ref double max, double outerMin, double outerMax, double minSize, double maxSize, double precision = 0.0)
        {
            RangeHelper.Normalize(ref min, ref max);
            RangeHelper.Normalize(ref outerMin, ref outerMax);
            double num1 = max - min;

            if (num1 < minSize)
            {
                max = min + minSize;
            }
            else if (num1 > maxSize)
            {
                max = min + maxSize;
            }
            double num2 = outerMax - outerMin;

            if (num1 > num2)
            {
                min = outerMin;
                max = outerMax;
            }
            else if (min < outerMin)
            {
                min = outerMin;
                max = outerMin + num1;
            }
            else if (max > outerMax)
            {
                max = outerMax;
                min = outerMax - num1;
            }
            if (precision <= 0.0)
            {
                return;
            }
            double num3 = num1 * precision;

            if (min - outerMin < num3)
            {
                min = outerMin;
            }
            if (outerMax - max >= num3)
            {
                return;
            }
            max = outerMax;
        }