docs.unity3d.com
    Show / Hide Table of Contents

    Class QuaternionCompressor

    A Smallest Three Quaternion Compressor Implementation

    Inheritance
    Object
    QuaternionCompressor
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Netcode
    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 the 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
    UInt32

    the Quaternion compressed as an unsigned integer

    DecompressQuaternion(ref Quaternion, UInt32)

    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

    UInt32 compressed

    the compressed quaternion

    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on 26 October 2023