Module src.util.cubic_polynomial
Module for handling and finding roots of cubic polynomaials
Used for bezier interpolation.
Classes
class CubicPolynomial (a: float, b: float, c: float, d: float)-
Args
a- Coefficient for the third degree term.
b- Coefficient for the second degree term.
c- Coefficient for the first degree term.
d- Coefficient for the constant term.
Methods
def get_function(self) ‑> Callable[[float], float]-
Makes a callable function from the coefficients
Gives the function f(t) = at^3 + bt^2 + ct + d
Returns
f- A callable function float \to float.
def solve(self, x: Union[float, NoneType] = 0) ‑> Tuple[complex, complex, complex]-
Solves the equation at^3 +bt^2 + ct + d = x by depressing the coefficients into a general cubic and using the substitution t = u - \frac{b}{3a}.
Args
x- The right hand side of the equation
Returns
A tuple of the three solutions, either real or complex