3#include <cgv/math/lin_solve.h>
13bool line_line_intersection(
const vec<T>& x1,
const vec<T>& d1,
const vec<T>& x2,
const vec<T>& d2, T& t1, T& t2, T eps = 0.00001)
15 mat<T> A(x1.dim(), 2);
18 vec<T> b = transpose(A) * (x1 - x2);
22 vec<T> s1 = x1 + t(0) * d1;
23 vec<T> s2 = x2 + t(1) * d2;
26 return length(s1 - s2) <= eps;
30bool line_circle_intersection(
const vec<T>& x,
const vec<T>& d,
const vec<T>& center,
const vec<T>& normal,
31 const T& radius, vec<T>& nearest_point, T eps = 0.00001)
37 T t = dot(normal, x) - dot(center, normal);
40 vec<T> v1 = x + t * d - center;
41 nearest_point = radius * normalize(v1) + center;
46 return std::fabs(length(v1) - radius) <= eps;