Class MathUtils


  • public final class MathUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void packTangentFrame​(float tangentX, float tangentY, float tangentZ, float bitangentX, float bitangentY, float bitangentZ, float normalX, float normalY, float normalZ, float[] quaternion)
      Packs the tangent frame represented by the specified tangent, bitangent, and normal into a quaternion.
      static void packTangentFrame​(float tangentX, float tangentY, float tangentZ, float bitangentX, float bitangentY, float bitangentZ, float normalX, float normalY, float normalZ, float[] quaternion, int offset)
      Packs the tangent frame represented by the specified tangent, bitangent, and normal into a quaternion.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • packTangentFrame

        public static void packTangentFrame​(float tangentX,
                                            float tangentY,
                                            float tangentZ,
                                            float bitangentX,
                                            float bitangentY,
                                            float bitangentZ,
                                            float normalX,
                                            float normalY,
                                            float normalZ,
                                            @NonNull @Size(min=4L)
                                            float[] quaternion)
        Packs the tangent frame represented by the specified tangent, bitangent, and normal into a quaternion.

        Reflection is preserved by encoding it as the sign of the w component in the resulting quaternion. Since -0 cannot always be represented on the GPU, this function computes a bias to ensure values are always either positive or negative, never 0. The bias is computed based on a per-element storage size of 2 bytes, making the resulting quaternion suitable for storage into an SNORM16 vector.

        Parameters:
        tangentX - the X component of the tangent
        tangentY - the Y component of the tangent
        tangentZ - the Z component of the tangent
        bitangentX - the X component of the bitangent
        bitangentY - the Y component of the bitangent
        bitangentZ - the Z component of the bitangent
        normalX - the X component of the normal
        normalY - the Y component of the normal
        normalZ - the Z component of the normal
        quaternion - a float array of at least size 4 for the quaternion result to be stored
      • packTangentFrame

        public static void packTangentFrame​(float tangentX,
                                            float tangentY,
                                            float tangentZ,
                                            float bitangentX,
                                            float bitangentY,
                                            float bitangentZ,
                                            float normalX,
                                            float normalY,
                                            float normalZ,
                                            @NonNull @Size(min=4L)
                                            float[] quaternion,
                                            @IntRange(from=0L)
                                            int offset)
        Packs the tangent frame represented by the specified tangent, bitangent, and normal into a quaternion.

        Reflection is preserved by encoding it as the sign of the w component in the resulting quaternion. Since -0 cannot always be represented on the GPU, this function computes a bias to ensure values are always either positive or negative, never 0. The bias is computed based on a per-element storage size of 2 bytes, making the resulting quaternion suitable for storage into an SNORM16 vector.

        Parameters:
        tangentX - the X component of the tangent
        tangentY - the Y component of the tangent
        tangentZ - the Z component of the tangent
        bitangentX - the X component of the bitangent
        bitangentY - the Y component of the bitangent
        bitangentZ - the Z component of the bitangent
        normalX - the X component of the normal
        normalY - the Y component of the normal
        normalZ - the Z component of the normal
        quaternion - a float array of at least size 4 for the quaternion result to be stored
        offset - offset, in elements, into the quaternion array to store the results