public static double NextDoubleInRealInterval(IRealInterval realInterval) { lock (random) { return random.NextDouble() * realInterval.Span() + realInterval.Min; } }
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; }
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); }