Table of Contents

Class

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

value float

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

value uint

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

value float
probabilityOfTrue float

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

angle float
radius float

Returns

float2

A 2D point as a float2 structure, 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

radius float
onUnitSphere float3

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

z float
theta float

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

minInclusive int

The minimum bound of the range (inclusive).

maxExclusive int

The maximum bound of the range (exclusive).

value uint

Returns

int

A uniformly random integer between minInclusive and maxExclusive.

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

minInclusive float

The minimum inclusive bound of the range.

maxInclusive float

The maximum inclusive bound of the range.

value float

The 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

axis float3
angle float

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

u1 float
u2 float
u3 float

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

value uint

Returns

ushort

A 16-bit unsigned integer value.