Foundation
Loading...
Searching...
No Matches
Classes | Typedefs | Functions
Foundation::Math Namespace Reference

Classes

union  FloatBits
 

Typedefs

using float4 = vec4
 
using float3 = vec3
 
using float2 = vec2
 
using float4x4 = mat4
 

Functions

bool decompose (mat4 const &m, float3 &scale, quat &rotation, float3 &transform)
 
mat4 infinitePerspectiveRHReverseZ (float fovY, float a, float zNear)
 
mat4 perspectiveRHReverseZ (float fovY, float a, float zNear, float zFar)
 
mat4 viewMatrixRHReverseZ (vec3 pos, quat rot)
 
float4 planeSymmetric (mat4 proj)
 
unsigned short quantizeFP16 (float v)
 
float quantizeFP32 (float v, int N)
 
float dequantizeFP16 (unsigned short h)
 
float quantizeFP32 (float v, int32_t N)
 
float dequantizeFP16 (uint16_t h)
 
uint32_t quantizeUnorm (float v, int32_t N)
 
float dequantizeUnorm (int32_t q, int32_t Nbits)
 
int32_t quantizeSnorm (float v, int32_t N)
 
float dequantizeSnorm (int32_t q, int32_t Nbits)
 
uint32_t quantizeSnormShifted (float v, int32_t Nbits)
 
float dequantizeSnormShifted (uint32_t q, int32_t Nbits)
 
float4 packQuaternionXYZPositionBit (quat const &q)
 
quat unpackQuaternionXYZPositionBit (float4 const &packed)
 

Typedef Documentation

◆ float2

using Foundation::Math::float2 = typedef vec2

◆ float3

using Foundation::Math::float3 = typedef vec3

◆ float4

using Foundation::Math::float4 = typedef vec4

◆ float4x4

using Foundation::Math::float4x4 = typedef mat4

Function Documentation

◆ decompose()

bool Foundation::Math::decompose ( mat4 const &  m,
float3 scale,
quat &  rotation,
float3 transform 
)
inline

Row-major. glm decompose fails to solve this one's perspective component correctly (FIXME in its docs). 0.0014 0 0 0 0 0 0.0014 0 0 -0.0014 0 0 2 0 2 1 Hence the implementation for only the TRS components. Assumes the matrix is affine.

◆ dequantizeFP16() [1/2]

float Foundation::Math::dequantizeFP16 ( uint16_t  h)

Reverse quantization of a half-precision (as defined by IEEE-754 fp16) floating point value Preserves Inf/NaN, flushes denormals to zero

◆ dequantizeFP16() [2/2]

float Foundation::Math::dequantizeFP16 ( unsigned short  h)

◆ dequantizeSnorm()

float Foundation::Math::dequantizeSnorm ( int32_t  q,
int32_t  Nbits 
)
inline

◆ dequantizeSnormShifted()

float Foundation::Math::dequantizeSnormShifted ( uint32_t  q,
int32_t  Nbits 
)
inline

◆ dequantizeUnorm()

float Foundation::Math::dequantizeUnorm ( int32_t  q,
int32_t  Nbits 
)
inline

◆ infinitePerspectiveRHReverseZ()

mat4 Foundation::Math::infinitePerspectiveRHReverseZ ( float  fovY,
float  a,
float  zNear 
)
inline

◆ packQuaternionXYZPositionBit()

float4 Foundation::Math::packQuaternionXYZPositionBit ( quat const &  q)
inline

◆ perspectiveRHReverseZ()

mat4 Foundation::Math::perspectiveRHReverseZ ( float  fovY,
float  a,
float  zNear,
float  zFar 
)
inline

◆ planeSymmetric()

float4 Foundation::Math::planeSymmetric ( mat4  proj)
inline

◆ quantizeFP16()

uint16_t Foundation::Math::quantizeFP16 ( float  v)

Quantize a float into half-precision (as defined by IEEE-754 fp16) floating point value Generates +-inf for overflow, preserves NaN, flushes denormals to zero, rounds to nearest Representable magnitude range: [6e-5; 65504] Maximum relative reconstruction error: 5e-4

◆ quantizeFP32() [1/2]

float Foundation::Math::quantizeFP32 ( float  v,
int  N 
)

◆ quantizeFP32() [2/2]

float Foundation::Math::quantizeFP32 ( float  v,
int32_t  N 
)

Quantize a float into a floating point value with a limited number of significant mantissa bits, preserving the IEEE-754 fp32 binary representation Generates +-inf for overflow, preserves NaN, flushes denormals to zero, rounds to nearest Assumes N is in a valid mantissa precision range, which is 1..23

◆ quantizeSnorm()

int32_t Foundation::Math::quantizeSnorm ( float  v,
int32_t  N 
)
inline

[-1, 1] range -> [-(1<< (Nbits - 1)) - 1, (1 << (Nbits - 1))] \in N e.g. Nbits = 10 -> [-511, 512] In transport you may want to add 1 << (Nbits - 1) to the quantized value to shift it to [0, 1 << NBits) range since you'd be packing complement int32 bits - truncation would result in a loss of precision To do this, use QuantizeSnormShifted and DequantizeSnormShifted

◆ quantizeSnormShifted()

uint32_t Foundation::Math::quantizeSnormShifted ( float  v,
int32_t  Nbits 
)
inline

◆ quantizeUnorm()

uint32_t Foundation::Math::quantizeUnorm ( float  v,
int32_t  N 
)
inline

◆ unpackQuaternionXYZPositionBit()

quat Foundation::Math::unpackQuaternionXYZPositionBit ( float4 const &  packed)
inline

◆ viewMatrixRHReverseZ()

mat4 Foundation::Math::viewMatrixRHReverseZ ( vec3  pos,
quat  rot 
)
inline