Ejemplo n.º 1
0
        public void Apply(int itercount = 1)
        {
            // This gets applied to the basemap.
            var overlay = world.GetLayer(layer);
            var pb      = new ProgressBar(itercount);

            for (int iter = 0; iter < itercount; iter++)
            {
                world.Mtx.WaitOne();
                pb.Update();
                // Pick a random plane.
                Point3d pt;

                do
                {
                    pt = (rand.NextPoint3d() - new Point3d(0.5, 0.5, 0.5)) * 2;
                } while (pt.Length2 > 1);
                double adj = (rand.Next() % 2 == 0) ? 1 : -1;
                for (int i = 0; i < world.Grid.Count; i++)
                {
                    var gpt = world.Grid[i];
                    if (gpt.Location.Dot(pt) > 0)
                    {
                        overlay[i] += adj;
                    }
                    else
                    {
                        overlay[i] -= adj;
                    }
                }
                world.Mtx.ReleaseMutex();
            }
        }
Ejemplo n.º 2
0
 public static byte[] NextBuffer(this IRandGen gen, byte[] buf)
 {
     for (int i = 0; i < buf.Length; i++)
     {
         buf[i] = gen.Next();
     }
     return(buf);
 }
Ejemplo n.º 3
0
        public static UInt64 NextUint64(this IRandGen gen)
        {
            UInt64 ret = 0;

            for (int i = 0; i < 8; i++)
            {
                ret = ret << 8 | gen.Next();
            }
            return(ret);
        }
Ejemplo n.º 4
0
        public static uint NextUint(this IRandGen gen)
        {
            uint ret = 0;

            for (int i = 0; i < 4; i++)
            {
                ret = ret << 8 | gen.Next();
            }
            return(ret);
        }
Ejemplo n.º 5
0
        public static int NextInt(this IRandGen gen)
        {
            // Read a big-endian integer from the generator
            int ret = 0;

            for (int i = 0; i < 4; i++)
            {
                ret = ret << 8 | gen.Next();
            }
            return(ret);
        }