7 float3 v_xyz = inLHS.xyz;
8 float3 v_yzx = inLHS.yzx;
9 float3 q_cross_p = (inRHS.yzx * v_xyz - v_yzx * inRHS).
yzx;
10 float3 q_cross_q_cross_p = (q_cross_p.yzx * v_xyz - v_yzx * q_cross_p).
yzx;
11 float3 v = inLHS.w * q_cross_p + q_cross_q_cross_p;
12 return inRHS + (v + v);
45 const float cOneOverSqrt2 = 0.70710678f;
46 const uint cNumBits = 9;
47 const uint cMask = (1u << cNumBits) - 1;
48 const uint cMaxValue = cMask - 1;
49 const int cHalfMaxValue = int(cMaxValue >> 1);
50 const float cScale = 2.0f * cOneOverSqrt2 / float(cMaxValue);
53 float3 v3 = float3(
float(
int(inValue & cMask) - cHalfMaxValue),
float(
int((inValue >> cNumBits) & cMask) - cHalfMaxValue),
float(
int(inValue >> (2 * cNumBits)) & cMask) - cHalfMaxValue) * cScale;
56 float4 v = float4(v3, sqrt(max(1.0f - dot(v3, v3), 0.0f)));
59 if ((inValue & 0x80000000u) != 0)
63 uint max_element = (inValue >> 29) & 3;
64 v = max_element == 0? v.wxyz : (max_element == 1? v.xwyz : (max_element == 2? v.xywz : v));
71 float tr = inCol0.x + inCol1.y + inCol2.z;
74 float s = sqrt(tr + 1.0f);
77 (inCol1.z - inCol2.y) * is,
78 (inCol2.x - inCol0.z) * is,
79 (inCol0.y - inCol1.x) * is,
84 if (inCol0.x > inCol1.y && inCol0.x > inCol2.z)
86 float s = sqrt(inCol0.x - (inCol1.y + inCol2.z) + 1);
90 (inCol1.x + inCol0.y) * is,
91 (inCol0.z + inCol2.x) * is,
92 (inCol1.z - inCol2.y) * is);
94 else if (inCol1.y > inCol2.z)
96 float s = sqrt(inCol1.y - (inCol2.z + inCol0.x) + 1);
99 (inCol1.x + inCol0.y) * is,
101 (inCol2.y + inCol1.z) * is,
102 (inCol2.x - inCol0.z) * is);
106 float s = sqrt(inCol2.z - (inCol0.x + inCol1.y) + 1);
109 (inCol0.z + inCol2.x) * is,
110 (inCol2.y + inCol1.z) * is,
112 (inCol0.y - inCol1.x) * is);
JPH_Quat JPH_QuatFromMat33(float3 inCol0, float3 inCol1, float3 inCol2)
Definition ShaderQuat.h:69