std::pair< T, T > intersection( const ray<T,2u>& ray, const circle<T>& circle ) { // check for no intersection const T a = dot( ray.direction(), ray.direction() ); const T b = T(2.) * sum( ray.direction() * ( ray.source() - circle.center() ) ); const T c = dot( circle.center(), circle.center() ) + dot( ray.source(), ray.source() ) - T(2.) * dot( ray.source(), circle.center() ) - sqr( circle.radius() ); return solve_quadratic_equation(a,b,c); }
int main() { auto p = solve_quadratic_equation(1, -1, -2)(); std::cout << p.first << ", " << p.second << std::endl; }
int main() { std::pair<complex, complex> result = solve_quadratic_equation(1, -1e20, 1); std::cout << result.first << ", " << result.second << std::endl; }