Class
- Namespace
- CoreFramework.Random
Provides utility functions for generating random values using random function and random noise function interfaces. This class includes methods for working with various data types and structures in random generation scenarios.
public static class NoiseRngUtils
- Inheritance
-
object
Methods
Bool(float)
Computes a boolean value based on a pseudo-random calculation.
public static bool Bool(float value)
Parameters
valuefloat
Returns
- bool
True if the pseudo-random value is less than or equal to 0.5; otherwise, false.
Byte(uint)
Converts a random uint value into a byte.
public static byte Byte(uint value)
Parameters
valueuint
Returns
- byte
A byte value.
Chance(float, float)
Determines whether a random event occurs based on the given probability.
public static bool Chance(float value, float probabilityOfTrue)
Parameters
valuefloatprobabilityOfTruefloat
Returns
- bool
True if the randomly generated value falls within the probability range, otherwise false.
InsideUnitCircle(float, float)
Generates a random 2D point inside a unit circle, maintaining a uniform distribution across its area.
public static float2 InsideUnitCircle(float angle, float radius)
Parameters
anglefloatradiusfloat
Returns
- float2
A 2D point as a
float2structure, representing the coordinates inside the unit circle.
InsideUnitSphere(float, float3)
Generates a random point inside or on the surface of a unit sphere (sphere with radius 1.0). Use Marsaglia's method to generate a point on the sphere, then scale by radius cube root
public static float3 InsideUnitSphere(float radius, float3 onUnitSphere)
Parameters
radiusfloatonUnitSpherefloat3
Returns
- float3
A float3 representing a random point inside or on the surface of a unit sphere.
OnUnitSphere(float, float)
Generates a random point on the surface of a unit sphere.
public static float3 OnUnitSphere(float z, float theta)
Parameters
zfloatthetafloat
Returns
- float3
A vector representing a random point on the unit sphere surface.
Range(int, int, uint)
Generates a uniformly random integer within the specified range using a random function and noise function.
public static int Range(int minInclusive, int maxExclusive, uint value)
Parameters
minInclusiveintThe minimum bound of the range (inclusive).
maxExclusiveintThe maximum bound of the range (exclusive).
valueuint
Returns
- int
A uniformly random integer between
minInclusiveandmaxExclusive.
Range(float, float, float)
Clamps and Remaps the specified value to the specified range.
public static float Range(float minInclusive, float maxInclusive, float value)
Parameters
minInclusivefloatThe minimum inclusive bound of the range.
maxInclusivefloatThe maximum inclusive bound of the range.
valuefloatThe Value
Returns
- float
A float representing a value within the specified range.
Rotation(float3, float)
Generates a random quaternion representing a rotation.
public static quaternion Rotation(float3 axis, float angle)
Parameters
axisfloat3anglefloat
Returns
- quaternion
A randomly generated quaternion representing a rotation.
RotationUniform(float, float, float)
Generates a quaternion representing a random 3D rotation with uniform distribution.
public static quaternion RotationUniform(float u1, float u2, float u3)
Parameters
u1floatu2floatu3float
Returns
- quaternion
A randomly generated quaternion with uniform distribution over 3D rotation space.
Uint16(uint)
A 16-bit unsigned integer value based on the provided unsigned integer value.
public static ushort Uint16(uint value)
Parameters
valueuint
Returns
- ushort
A 16-bit unsigned integer value.