| 99 | } |
| 100 | |
| 101 | U32 xMathSolveCubic(F32 a, F32 b, F32 c, F32 d, F32* x1, F32* x2, F32* x3) |
| 102 | { |
| 103 | F32 arecip; // |
| 104 | F32 fA; // p |
| 105 | F32 fB; // q |
| 106 | F32 fOffset; // |
| 107 | F32 fDiscr; // |
| 108 | F32 fHalfB; // |
| 109 | F32 fTemp; |
| 110 | F32 fDist; |
| 111 | F32 fAngle; |
| 112 | F32 fCos; // |
| 113 | F32 fSin; // |
| 114 | |
| 115 | F32 temp_f1; |
| 116 | F32 temp_f1_2; |
| 117 | F32 temp_f1_3; |
| 118 | F32 temp_f28_2; |
| 119 | F32 temp_f29; |
| 120 | F32 var_f1; |
| 121 | |
| 122 | if (a == 0.0f) |
| 123 | { |
| 124 | return xMathSolveQuadratic(b, c, d, x1, x2); |
| 125 | } |
| 126 | if (a != 1.0f) |
| 127 | { |
| 128 | arecip = 1.0f / a; |
| 129 | b *= arecip; |
| 130 | c *= arecip; |
| 131 | d *= arecip; |
| 132 | } |
| 133 | fA = 0.33333334f * ((3.0f * c) - b * b); |
| 134 | fB = 0.037037037f * ((27.0f * d) + ((2.0f * (b * b * b)) - (9.0f * b * c))); |
| 135 | fOffset = 0.33333334f * b; |
| 136 | fDiscr = (0.25f * (fB * fB)) + (0.037037037f * (fA * (fA * fA))); |
| 137 | fHalfB = 0.5f * fB; |
| 138 | if ((F32)__fabs(fDiscr) < 0.000001f) |
| 139 | { |
| 140 | fDiscr = 0.0f; |
| 141 | } |
| 142 | if (fDiscr > 0.0f) |
| 143 | { |
| 144 | temp_f1 = xsqrt(fDiscr); |
| 145 | temp_f1_2 = -fHalfB + temp_f1; |
| 146 | if (temp_f1_2 >= 0.0f) |
| 147 | { |
| 148 | *x1 = xpow(temp_f1_2, 0.33333334f); |
| 149 | } |
| 150 | else |
| 151 | { |
| 152 | *x1 = -xpow(-temp_f1_2, 0.33333334f); |
| 153 | } |
| 154 | temp_f1_3 = -fHalfB - temp_f1; |
| 155 | if (temp_f1_3 >= 0.0f) |
| 156 | { |
| 157 | *x1 += xpow(temp_f1_3, 0.33333334f); |
| 158 | } |
nothing calls this directly
no test coverage detected