1using System.Collections.Generic;
24 List<float> solutions =
new List<float>();
27 float determinant = b * b - 4 * a * c;
28 if (determinant < 0.0f)
return solutions;
31 float u = (-b - Mathf.Sqrt(b * b - 4.0f * a * c)) / (2.0f * a);
32 if (determinant == 0.0f) {
38 float v = (-b + Mathf.Sqrt(b * b - 4.0f * a * c)) / (2.0f * a);
39 solutions.Add(Mathf.Min(u, v));
40 solutions.Add(Mathf.Max(u, v));
Utility class for maths functions.
static List< float > SolveQuadraticEquation(float a, float b, float c)
Solve and quadratic equation in the form ax^2 + bx + c = 0.