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 float cScale = 2.0f * cOneOverSqrt2 / float(cMaxValue);
52 float3 v3 = float3(
float(inValue & cMask),
float((inValue >> cNumBits) & cMask),
float((inValue >> (2 * cNumBits)) & cMask)) * cScale - float3(cOneOverSqrt2, cOneOverSqrt2, cOneOverSqrt2);
55 float4 v = float4(v3, sqrt(max(1.0f - dot(v3, v3), 0.0f)));
58 if ((inValue & 0x80000000u) != 0)
62 uint max_element = (inValue >> 29) & 3;
63 v = max_element == 0? v.wxyz : (max_element == 1? v.xwyz : (max_element == 2? v.xywz : v));
70 float tr = inCol0.x + inCol1.y + inCol2.z;
73 float s = sqrt(tr + 1.0f);
76 (inCol1.z - inCol2.y) * is,
77 (inCol2.x - inCol0.z) * is,
78 (inCol0.y - inCol1.x) * is,
83 if (inCol0.x > inCol1.y && inCol0.x > inCol2.z)
85 float s = sqrt(inCol0.x - (inCol1.y + inCol2.z) + 1);
89 (inCol1.x + inCol0.y) * is,
90 (inCol0.z + inCol2.x) * is,
91 (inCol1.z - inCol2.y) * is);
93 else if (inCol1.y > inCol2.z)
95 float s = sqrt(inCol1.y - (inCol2.z + inCol0.x) + 1);
98 (inCol1.x + inCol0.y) * is,
100 (inCol2.y + inCol1.z) * is,
101 (inCol2.x - inCol0.z) * is);
105 float s = sqrt(inCol2.z - (inCol0.x + inCol1.y) + 1);
108 (inCol0.z + inCol2.x) * is,
109 (inCol2.y + inCol1.z) * is,
111 (inCol0.y - inCol1.x) * is);
JPH_Quat JPH_QuatFromMat33(float3 inCol0, float3 inCol1, float3 inCol2)
Definition ShaderQuat.h:68