3#include <cgv/math/lin_solve.h>
10bool 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 vec<T> b = transpose(A)*(x1-x2);
19 vec<T> s1 = x1 + t(0)*d1;
20 vec<T> s2 = x2 + t(1)*d2;
23 return length(s1-s2)<= eps;
27bool line_circle_intersection(
const vec<T>& x,
const vec<T>& d,
const vec<T>& center,
const vec<T>& normal,
28 const T& radius, vec<T>& nearest_point, T eps=0.00001)
35 T t = dot(normal,x)-dot(center,normal);
39 vec<T> v1 = x+t*d-center;
40 nearest_point = radius*normalize(v1)+center;
45 return ( fabs(length(v1)-radius) <= eps);
50bool ray_plane_intersection(
const vec<T>& x,
const vec<T>& d,
const vec<T>& plane, T& t)
56 for(
unsigned i = 0; i < n; i++)