예제 #1
0
        public static long Project(this Range <double> fromRange, double value, Range <long> targetRange)
        {
            double num1 = RangeHelper.Size(fromRange);
            long   num2 = RangeHelper.Size(targetRange);

            if (num1 == 0.0 || num2 == 0L)
            {
                return(targetRange.Minimum);
            }
            double num3 = (value - fromRange.Minimum) / num1;

            return(targetRange.Minimum + (long)(num3 * (double)num2));
        }
예제 #2
0
        public static double Project(this Range <long> fromRange, long value, Range <double> targetRange)
        {
            long   num1 = RangeHelper.Size(fromRange);
            double num2 = RangeHelper.Size(targetRange);

            if (num1 == 0L || num2 == 0.0)
            {
                return(targetRange.Minimum);
            }
            DoubleR10 doubleR10 = (DoubleR10)(value - fromRange.Minimum) / (DoubleR10)num1;

            return(targetRange.Minimum + (double)doubleR10 * num2);
        }
예제 #3
0
        public static double Project(this Range <double> fromRange, double value, Range <double> targetRange)
        {
            double d1 = RangeHelper.Size(fromRange);
            double d2 = RangeHelper.Size(targetRange);

            if (d1 == 0.0 || d2 == 0.0)
            {
                if (fromRange.Minimum <= value && value <= fromRange.Maximum)
                {
                    return(targetRange.Minimum);
                }
                return(double.NaN);
            }
            if (double.IsInfinity(d1) || double.IsInfinity(d2))
            {
                return(RangeHelper.ProjectOverflowingDoubles(fromRange, value, targetRange));
            }
            double num = (value - fromRange.Minimum) / d1;

            return(targetRange.Minimum + num * d2);
        }