Class QuaternionCompressor
A Smallest Three Quaternion Compressor Implementation
Inherited Members
Namespace: Unity.Netcode
Assembly: Unity.Netcode.Runtime.dll
Syntax
public static class QuaternionCompressor
Remarks
Explanation of why "The smallest three": Since a normalized Quaternion's unit value is 1.0f: xx + yy + zz + ww = MM (where M is the magnitude of the vector) If w was the largest value and the quaternion is normalized: M = 1.0f (which M * M would still yield 1.0f) ww = MM - (xx + yy + zz) or Mathf.Sqrt(1.0f - (xx + yy + zz)) w = Math.Sqrt(1.0f - (xx + yy + zz)) Using the largest number avoids potential loss of precision in the smallest three values.
Methods
CompressQuaternion(ref Quaternion)
Compresses a Quaternion into an unsigned integer
Declaration
public static uint CompressQuaternion(ref Quaternion quaternion)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | the Quaternion to be compressed |
Returns
Type | Description |
---|---|
uint | the Quaternion compressed as an unsigned integer |
DecompressQuaternion(ref Quaternion, uint)
Decompress a compressed quaternion
Declaration
public static void DecompressQuaternion(ref Quaternion quaternion, uint compressed)
Parameters
Type | Name | Description |
---|---|---|
Quaternion | quaternion | quaternion to store the decompressed values within |
uint | compressed | the compressed quaternion |