quadratic_equation

giant.ray_tracer.shapes.ellipsoid:

giant.ray_tracer.shapes.ellipsoid.quadratic_equation(a, b, c)

This helper function finds the routes of a quadratic equation with coefficients a, b, c

The quadratic equation is given by

\[\frac{-b\pm\sqrt{b^2-4ac}}{2a}\]

for an equation of the form

\[ax^2+bx+c=0\]

This function is vectorized so it can accept either scalars or arrays as long as they are broadcastable.

Note that this function will return Nan for places where the discriminant is negative unless the input is already complex.

Parameters:
  • a (SCALAR_OR_ARRAY) – the a coefficient(s) of the equation(s)

  • b (SCALAR_OR_ARRAY) – the b coefficient(s) of the equation(s)

  • c (SCALAR_OR_ARRAY) – the c coefficient(s) of the equation(s)

Returns:

the positive and negative roots of the equation as a tuple of floats or arrays. The negative root is first

Return type:

Union[Tuple[Union[Real, Complex], Union[Real, Complex]], Tuple[np.ndarray, np.ndarray]]