Math utility methods. More...
Classes | |
struct | FastAbs |
Represents a structure that allows quick setting of the sign bit of floats using field offsets. More... | |
Static Public Member Functions | |
static int | BitScanReverse (int v) |
Finds the index of the most significant set bit (1-bit) in a 32-bit integer. More... | |
static int | BitScanReverse (long v) |
Finds the index of the most significant set bit (1-bit) in a 64-bit integer. More... | |
static int | BitScanReverse (uint v) |
Finds the index of the most significant set bit (1-bit) in a 32-bit unsigned integer. More... | |
static int | BitScanReverse (ulong v) |
Finds the index of the most significant set bit (1-bit) in a 64-bit unsigned integer. More... | |
static int | BitsRequiredForNumber (int n) |
Determines the number of bits required to represent the specified integer. More... | |
static int | BitsRequiredForNumber (uint n) |
Determines the number of bits required to represent a uint value. More... | |
static int | BytesRequiredForBits (int b) |
Calculates the number of bytes required to store the specified number of bits. More... | |
static short | BytesRequiredForBits (short b) |
Calculates the number of bytes required to store the specified number of bits. More... | |
static int | CeilToInt (double value) |
Rounds a double value up to the nearest integer. More... | |
static double | Clamp (double v, double min, double max) |
Clamps a double value to the specified range. More... | |
static float | Clamp (float v, float min, float max) |
Clamps a float value to the specified range. More... | |
static int | Clamp (int v, int min, int max) |
Clamps an integer value to the specified range. More... | |
static uint | Clamp (uint v, uint min, uint max) |
Clamps an unsigned integer value to the specified range. More... | |
static double | Clamp01 (double v) |
Clamps a double value to the range [0, 1]. More... | |
static float | Clamp01 (float v) |
Clamps a float value to the range [0, 1]. More... | |
static byte | ClampToByte (int v) |
Clamps an integer value to the range [0, 255] and returns it as a byte. More... | |
static double | CosineInterpolate (double a, double b, double t) |
Performs cosine interpolation between two values. More... | |
static int | CountSetBits (ulong x) |
Counts the number of bits set to 1 in a ulong value. More... | |
static int | CountUsedBitsMinOne (uint value) |
Counts the number of bits set to 1 in a uint value, minus one. More... | |
static int | FloorToInt (double value) |
Rounds a double value down to the nearest integer. More... | |
static int | IntsRequiredForBits (int b) |
Calculates the number of integers required to store the specified number of bits. More... | |
static double | Lerp (double a, double b, double t) |
Linearly interpolates between two double values. More... | |
static float | Lerp (float a, float b, float t) |
Linearly interpolates between two float values. More... | |
static double | MicrosecondsToSeconds (long microseconds) |
Converts microseconds to seconds. More... | |
static long | MillisecondsToMicroseconds (long milliseconds) |
Converts milliseconds to microseconds. More... | |
static double | MillisecondsToSeconds (double seconds) |
Converts milliseconds to seconds. More... | |
static uint | Min (uint v, uint max) |
Returns the minimum of two unsigned integer values. More... | |
static uint | NextPowerOfTwo (uint v) |
Calculates the next power of two greater than or equal to a given uint value. More... | |
static unsafe string | PrintBits (byte *data, int count) |
Converts a byte array to a string representation of its bits. More... | |
static uint | QuaternionCompress (Quaternion rot) |
Primary Compression Method. Converts a quaternion into a ulong buffer. Depending on size most of the top bits will be 0. More... | |
static Quaternion | QuaternionDecompress (uint buffer) |
Primary Decompression Method. Decompress the 3 channels and missing channel ID from the serialized ULong buffer. More... | |
static long | SecondsToMicroseconds (double seconds) |
Converts seconds to microseconds. More... | |
static long | SecondsToMilliseconds (double seconds) |
Converts seconds to milliseconds. More... | |
static unsafe int | SizeOfBits< T > () |
Returns the size of the specified unmanaged type in bits. More... | |
static int | ZigZagDecode (int i) |
Decodes a ZigZag encoded integer. More... | |
static long | ZigZagDecode (long i) |
Decodes a ZigZag encoded long integer. More... | |
static int | ZigZagEncode (int i) |
Encodes an integer using ZigZag encoding. More... | |
static long | ZigZagEncode (long i) |
Encodes a long integer using ZigZag encoding. More... | |
Math utility methods.
|
static |
Finds the index of the most significant set bit (1-bit) in a 32-bit integer.
v | The 32-bit integer to scan. |
|
static |
Finds the index of the most significant set bit (1-bit) in a 64-bit integer.
v | The 64-bit integer to scan. |
|
static |
Finds the index of the most significant set bit (1-bit) in a 32-bit unsigned integer.
v | The 32-bit unsigned integer to scan. |
|
static |
Finds the index of the most significant set bit (1-bit) in a 64-bit unsigned integer.
v | The 64-bit unsigned integer to scan. |
|
static |
Determines the number of bits required to represent the specified integer.
n | The integer to evaluate. |
|
static |
Determines the number of bits required to represent a uint value.
n | The uint value to evaluate. |
|
static |
Calculates the number of bytes required to store the specified number of bits.
b | The number of bits. |
|
static |
Calculates the number of bytes required to store the specified number of bits.
b | The number of bits. |
|
static |
Rounds a double value up to the nearest integer.
value | The double value to round up. |
|
static |
Clamps a double value to the specified range.
v | The value to clamp. |
min | The minimum value of the range. |
max | The maximum value of the range. |
|
static |
Clamps a float value to the specified range.
v | The value to clamp. |
min | The minimum value of the range. |
max | The maximum value of the range. |
|
static |
Clamps an integer value to the specified range.
v | The value to clamp. |
min | The minimum value of the range. |
max | The maximum value of the range. |
|
static |
Clamps an unsigned integer value to the specified range.
v | The value to clamp. |
min | The minimum value of the range. |
max | The maximum value of the range. |
|
static |
Clamps a double value to the range [0, 1].
v | The value to clamp. |
|
static |
Clamps a float value to the range [0, 1].
v | The value to clamp. |
|
static |
Clamps an integer value to the range [0, 255] and returns it as a byte.
v | The value to clamp. |
|
static |
Performs cosine interpolation between two values.
a | The start value. |
b | The end value. |
t | The interpolation factor, typically between 0 and 1. |
|
static |
Counts the number of bits set to 1 in a ulong value.
x | The ulong value to count bits in. |
|
static |
Counts the number of bits set to 1 in a uint value, minus one.
value | The uint value to count bits in. |
|
static |
Rounds a double value down to the nearest integer.
value | The double value to round down. |
|
static |
Calculates the number of integers required to store the specified number of bits.
b | The number of bits. |
|
static |
Linearly interpolates between two double values.
a | The start value. |
b | The end value. |
t | The interpolation factor, typically between 0 and 1. |
|
static |
Linearly interpolates between two float values.
a | The start value. |
b | The end value. |
t | The interpolation factor, typically between 0 and 1. |
|
static |
Converts microseconds to seconds.
microseconds | The time in microseconds. |
|
static |
Converts milliseconds to microseconds.
milliseconds | The time in milliseconds. |
|
static |
Converts milliseconds to seconds.
seconds | The time in milliseconds. |
|
static |
Returns the minimum of two unsigned integer values.
v | The first value. |
max | The second value. |
|
static |
Calculates the next power of two greater than or equal to a given uint value.
v | The uint value to evaluate. |
|
static |
Converts a byte array to a string representation of its bits.
data | Pointer to the byte array. |
count | The number of bytes to convert. |
|
static |
Primary Compression Method. Converts a quaternion into a ulong buffer. Depending on size most of the top bits will be 0.
rot | The quaternion to be compressed |
|
static |
Primary Decompression Method. Decompress the 3 channels and missing channel ID from the serialized ULong buffer.
buffer | The ulong that represents the compressed quaternion. |
|
static |
Converts seconds to microseconds.
seconds | The time in seconds. |
|
static |
Converts seconds to milliseconds.
seconds | The time in seconds. |
|
static |
Returns the size of the specified unmanaged type in bits.
T | The unmanaged type. |
T | : | unmanaged |
|
static |
Decodes a ZigZag encoded integer.
i | The ZigZag encoded integer to decode. |
|
static |
Decodes a ZigZag encoded long integer.
i | The ZigZag encoded long integer to decode. |
|
static |
Encodes an integer using ZigZag encoding.
i | The integer to encode. |
|
static |
Encodes a long integer using ZigZag encoding.
i | The long integer to encode. |