3#include <cgv/media/axis_aligned_box.h>
9 bool update_range(T lb, T ub, T o, T d,
unsigned i,
unsigned& i_min,
unsigned& i_max, T& t_min, T& t_max, T epsilon) {
11 if (std::abs(d) < epsilon)
12 return o >= lb && o <= ub;
32 template <
typename T, cgv::type::u
int32_type N>
33 bool ray_axis_aligned_box_intersection(
41 T t_min = -std::numeric_limits<T>::max();
42 T t_max = std::numeric_limits<T>::max();
44 unsigned i_min, i_max;
45 for (
unsigned i = 0; i < N; ++i)
46 if (!update_range(lb[i], ub[i], origin[i], direction[i], i, i_min, i_max, t_min, t_max, epsilon))
49 if (t_max < 0 || t_min > t_max)
59 p_result = origin + t_result * direction;
62 n_result[i_min] = direction[i_min] > T(0) ? T(-1) : T(1);
A vector with zero based index.
void zeros()
fill the vector with zeros