Roots¶
Functions to compute roots of simple equations.
#include <Imath/ImathRoots.h>

template<class T>
constexpr int Imath::solveLinear(T a, T b, T &x)¶ Solve for x in the linear equation:
a * x + b == 0
 Returns:
1 if the equation has a solution, 0 if there is no solution, and 1 if all real numbers are solutions.

template<class T>
constexpr int Imath::solveQuadratic(T a, T b, T c, T x[2])¶ Solve for x in the quadratic equation:
a * x*x + b * x + c == 0
 Returns:
2 if the equation has two solutions, 1 if the equation has a single solution, 0 if there is no solution, and 1 if all real numbers are solutions.

template<class T>
constexpr int Imath::solveNormalizedCubic(T r, T s, T t, T x[3])¶ Solve for x in the normalized cubic equation:
The equation is solved using Cardano’s Formula; even though only real solutions are produced, some intermediate results are complex (std::complex<T>).x*x*x + r * x*x + s * x + t == 0
 Returns:
0 if there is no solution, and 1 if all real numbers are solutions, otherwise return the number of solutions.

template<class T>
constexpr int Imath::solveCubic(T a, T b, T c, T d, T x[3])¶ Solve for x in the cubic equation:
The equation is solved using Cardano’s Formula; even though only real solutions are produced, some intermediate results are complex (std::complex<T>).a * x*x*x + b * x*x + c * x + d == 0
 Returns:
0 if there is no solution, and 1 if all real numbers are solutions, otherwise return the number of solutions.