/// <summary> /// Returns a uniformly distributed double in the closed interval /// [0.0, 1.0]. Note, that two random values are used to make all 53 /// bits random. /// </summary> public static double UniformDoubleFullClosed(this IRandomUniform rnd) { if (rnd.GeneratesFullDoubles) { return(rnd.UniformDoubleClosed()); } long r = ((~0xfL & (long)rnd.UniformInt()) << 22) | ((long)rnd.UniformInt() >> 5); return(r * (1.0 / 9007199254740991.0)); }
public static V3d UniformV3dClosed(this IRandomUniform rnd, Box3d box) { return(box.Lerp(rnd.UniformDoubleClosed(), rnd.UniformDoubleClosed(), rnd.UniformDoubleClosed())); }
public static V3d UniformV3dClosed(this IRandomUniform rnd) { return(new V3d(rnd.UniformDoubleClosed(), rnd.UniformDoubleClosed(), rnd.UniformDoubleClosed())); }
public static V2d UniformV2dClosed(this IRandomUniform rnd, Box2d box) { return(new V2d(box.Min.X + rnd.UniformDoubleClosed() * (box.Max.X - box.Min.X), box.Min.Y + rnd.UniformDoubleClosed() * (box.Max.Y - box.Min.Y))); }