1 #ifndef VTESTBED_GEOMETRY_RAY_HH 2 #define VTESTBED_GEOMETRY_RAY_HH 6 #include <vtestbed/geometry/types.hh> 12 template <
class T,
int N>
16 static constexpr
const int dimensions = N;
17 using scalar_type = T;
18 using value_type = Vertex<T,N>;
19 using reference = value_type&;
20 using const_reference =
const value_type&;
23 value_type _origin{T{}};
24 value_type _direction{T{}};
30 Ray& operator=(
const Ray&) =
default;
32 Ray& operator=(
Ray&&) =
default;
36 Ray(const_reference origin, const_reference direction):
38 _direction(direction) {}
40 inline const_reference
41 origin()
const noexcept {
45 inline const_reference
46 direction()
const noexcept {
47 return this->_direction;
52 this->_direction = -this->_direction;
56 contains(
const value_type& c, T eps)
const {
57 value_type ca = c-origin();
58 return !any(abs(cross(ca,direction())) > eps);
63 return out << rhs.origin() <<
' ' << rhs.direction();
72 #endif // vim:filetype=cpp