Class MathUtils
- java.lang.Object
-
- com.google.android.filament.MathUtils
-
public final class MathUtils extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidpackTangentFrame(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 voidpackTangentFrame(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.
-
-
-
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 tangenttangentY- the Y component of the tangenttangentZ- the Z component of the tangentbitangentX- the X component of the bitangentbitangentY- the Y component of the bitangentbitangentZ- the Z component of the bitangentnormalX- the X component of the normalnormalY- the Y component of the normalnormalZ- the Z component of the normalquaternion- 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 tangenttangentY- the Y component of the tangenttangentZ- the Z component of the tangentbitangentX- the X component of the bitangentbitangentY- the Y component of the bitangentbitangentZ- the Z component of the bitangentnormalX- the X component of the normalnormalY- the Y component of the normalnormalZ- the Z component of the normalquaternion- a float array of at least size 4 for the quaternion result to be storedoffset- offset, in elements, into the quaternion array to store the results
-
-