Example #1
0
        /// <summary>
        /// Returns a uniformly distributed double in the open interval
        /// (0.0, 1.0). Note, that two random values are used to make all 53
        /// bits random.
        /// </summary>
        public static double UniformDoubleFullOpen(this IRandomUniform rnd)
        {
            if (rnd.GeneratesFullDoubles)
            {
                return(rnd.UniformDoubleOpen());
            }
            long r;

            do
            {
                r = ((~0xfL & (long)rnd.UniformInt()) << 22)
                    | ((long)rnd.UniformInt() >> 5);
            }while (r == 0);
            return(r * (1.0 / 9007199254740992.0));
        }
Example #2
0
 public static V3d UniformV3dOpen(this IRandomUniform rnd, Box3d box)
 {
     return(box.Lerp(rnd.UniformDoubleOpen(),
                     rnd.UniformDoubleOpen(),
                     rnd.UniformDoubleOpen()));
 }
Example #3
0
 public static V3d UniformV3dOpen(this IRandomUniform rnd)
 {
     return(new V3d(rnd.UniformDoubleOpen(),
                    rnd.UniformDoubleOpen(),
                    rnd.UniformDoubleOpen()));
 }
Example #4
0
 public static V2d UniformV2dOpen(this IRandomUniform rnd, Box2d box)
 {
     return(new V2d(box.Min.X + rnd.UniformDoubleOpen() * (box.Max.X - box.Min.X),
                    box.Min.Y + rnd.UniformDoubleOpen() * (box.Max.Y - box.Min.Y)));
 }