MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / xMathSolveQuadratic

Function xMathSolveQuadratic

src/SB/Core/x/xMath.cpp:50–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50U32 xMathSolveQuadratic(F32 a, F32 b, F32 c, F32* x1, F32* x2)
51{
52 F32 d;
53 F32 dx;
54 F32 p;
55
56 if (a == 0.0f)
57 {
58 if (b == 0.0f)
59 {
60 return 0;
61 }
62
63 *x1 = -c / b;
64 return 1;
65 }
66
67 d = b * b - (4.0f * a * c);
68
69 if (d < 0.0f)
70 {
71 return 0;
72 }
73
74 dx = 1.0f / (2.0f * a);
75
76 *x1 = -b * dx;
77
78 if (d == 0.0f)
79 {
80 return 1;
81 }
82
83 *x2 = *x1;
84
85 p = dx * xsqrt(d);
86
87 if (a > 0.0f)
88 {
89 *x1 -= p;
90 *x2 += p;
91 }
92 else
93 {
94 *x1 += p;
95 *x2 -= p;
96 }
97
98 return 2;
99}
100
101U32 xMathSolveCubic(F32 a, F32 b, F32 c, F32 d, F32* x1, F32* x2, F32* x3)
102{

Callers 3

xMathSolveCubicFunction · 0.70
zEntPickup_DropFunction · 0.50
iSphereIsectRayFunction · 0.50

Calls 1

xsqrtFunction · 0.85

Tested by

no test coverage detected