docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class QuaternionCompressor

    A Smallest Three Quaternion Compressor Implementation

    Inheritance
    object
    QuaternionCompressor
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)