/** * @param min * @param max * @return Random integer from min (inclusive) to max (inclusive) */ public int nextInt(int min, int max) { return min + nextInt(max - min + 1); }
@Override public void onEmission(EnergyRangeGeneratorComponent component, ParticleData particleData, Random random) { particleData.energy = random.nextFloat(component.minEnergy, component.maxEnergy); } }
/** * @param min * @param max * @return Random long from min (inclusive) to max (inclusive) */ public long nextLong(long min, long max) { return min + nextLong(max - min + 1); }
/** * Randomly generates a default color for the player via a random int generator using FastRandom object. * * @return a Color object with the player's default color. */ private Color defaultPlayerColor() { Random rng = new FastRandom(); List<Color> colors = CieCamColors.L65C65; return colors.get(rng.nextInt(colors.size())); } }
/** * Generates the player's default name. The default name is the string "Player" followed by a random 5 digit code ranging from 10000 to 99999. * * @return a String with the player's default name. */ private static String defaultPlayerName() { return "Player" + new FastRandom().nextInt(10000, 99999); }
public NoiseTest(Noise noiseGen) { this.noiseGen = noiseGen; this.rng = new FastRandom(0xBEEF); }
/** * Returns a unit vector (length = 1) Vector3f whose components range from -1 (inclusive) to 1 (inclusive) * * @return The vector */ public Vector3f nextUnitVector3f() { return nextVector3f(1.0f); }
/** * @param max * @return Random integer from 0 (inclusive) to max (exclusive) */ public int nextInt(int max) { return (int) (max * nextDouble()); }
/** * Calculates a normal distributed value (using the polar method). * * <code>nextGuassian(1,1)</code> is equivalent to {@link #nextGaussian()}. * * @param mean the mean value of the distribution * @param stdDev the standard deviation of the distribution * * @return The value */ public double nextGaussian(double mean, double stdDev) { return mean + stdDev * nextGaussian(); } }
/** * @return Random boolean */ public boolean nextBoolean() { return nextInt() < 0; }
/** * Randomises a provided Vector3f so its components range from min (inclusive) to max * * @param min * @param max * @param output * @return */ public Vector3f nextVector3f(float min, float max, Vector3f output) { output.set(nextFloat(min, max), nextFloat(min, max), nextFloat(min, max)); return output; }
/** * Randomises a provided Vector3f so its components range from -1.0 (inclusive) to 1.0 (inclusive) * * @param output * @return */ public Vector3f nextVector3f(Vector3f output) { return nextVector3f(-1.0f, 1.0f, output); }
/** * @return Random double from 0 (inclusive) to 1 (exclusive) */ public double nextDouble() { return (nextLong() & 0x7FFFFFFFFFFFFFFFL) / (Long.MAX_VALUE + 1.0); }
/** * @param max * @return Random long from 0 (inclusive) to max (exclusive) */ public long nextLong(long max) { return (long) (max * nextDouble()); }
/** * @return Random float from 0 (inclusive) to 1 (exclusive) */ public float nextFloat() { return (nextInt() & 0x7FFFFFFF) / (Integer.MAX_VALUE + 1.0f); }
private static void randomizeParticle(final ParticlePool pool, final int index) { final int index3 = index * 3; final int index4 = index * 4; pool.energy[index] = random.nextFloat(); for (int i = 0; i < 3; i++) { pool.position[index3 + i] = random.nextFloat(); pool.previousPosition[index3 + i] = random.nextFloat(); pool.velocity[index3 + i] = random.nextFloat(); pool.scale[index3 + i] = random.nextFloat(); } for (int i = 0; i < 4; i++) { pool.color[index4 + i] = random.nextFloat(); } }
/** * Returns a Vector3f whose components range from -1.0 (inclusive) to 1.0 (inclusive) * * @return The vector */ public Vector3f nextVector3f() { return nextVector3f(new Vector3f()); }
/** * @param min * @param max * @return Random double from min (inclusive) to max (inclusive) */ public double nextDouble(double min, double max) { return min + (max - min) * (nextLong() & 0x7FFFFFFFFFFFFFFFL) / Long.MAX_VALUE; }
/** * @param min * @param max * @return Random float from min (inclusive) to max (inclusive) */ public float nextFloat(float min, float max) { return min + (max - min) * (nextInt() & 0x7FFFFFFF) / Integer.MAX_VALUE; }