Example #1
0
 public static double NextDoubleInRealInterval(IRealInterval realInterval)
 {
     lock (random)
     {
         return random.NextDouble() * realInterval.Span() + realInterval.Min;
     }
 }
Example #2
0
        public static double BoundBy(this double dVal, IRealInterval interval)
        {
            if (dVal < interval.Min)
            {
                return interval.Min;
            }

            if (dVal > interval.Max)
            {
                return interval.Max;
            }
            return dVal;
        }
Example #3
0
 public static bool Intersects(this IRealInterval lhs, IRealInterval rhs)
 {
     var newMin = Math.Max(lhs.Min, rhs.Min);
     var newMax = Math.Min(lhs.Max, rhs.Max);
     return (newMin <= newMax);
 }