Example #1
0
        /// <summary>
        /// from a givne percent, from 0 to 1,
        /// get the index corresponding
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="collection">list</param>
        /// <param name="percent">from 0 to 1</param>
        /// <returns>index found from percent</returns>
        public static int GetIndexFromPercent <T>(this T[] collection, float percent)
        {
            float remapped = ExtMathf.Remap(percent, 0, 1, 0, collection.Length);
            int   index    = (int)remapped;

            return(index);
        }
Example #2
0
        public static double RemapFromSeedDecimal(double min, double max, System.Random randomSeed)
        {
            double zeroToOneValue = randomSeed.NextDouble();
            double minToMaxValue  = ExtMathf.Remap(zeroToOneValue, 0, 1, min, max);

            return(minToMaxValue);
        }
Example #3
0
        public static float RemapFromSeedDecimal(float min, float max, System.Random randomSeed)
        {
            float zeroToOneValue = (float)randomSeed.NextDouble();
            float minToMaxValue  = ExtMathf.Remap(zeroToOneValue, 0, 1, min, max);

            return(minToMaxValue);
        }
Example #4
0
        /// <summary>
        /// here we have a min & max, we remap the random 0,1 value finded to this min&max
        /// warning: we cast it into an int at the end
        /// use:
        /// System.Random seed = ExtRandom.Seedrandom("hash");
        /// int randomInt = ExtRandom.RemapFromSeed(0, 50, seed);
        /// </summary>
        public static int RemapFromSeed(double min, double max, System.Random randomSeed)
        {
            double zeroToOneValue = randomSeed.NextDouble();
            int    minToMaxValue  = (int)ExtMathf.Remap(zeroToOneValue, 0, 1, min, max);

            return(minToMaxValue);
        }