20 #ifndef ANTKEEPER_GEOM_PRIMITIVES_INTERSECTION_HPP
21 #define ANTKEEPER_GEOM_PRIMITIVES_INTERSECTION_HPP
42 template <
class T, std::
size_t N>
46 if (cos_theta != T{0})
56 template <
class T, std::
size_t N>
72 template <
class T, std::
size_t N>
75 T t0 = -std::numeric_limits<T>::infinity();
76 T t1 = std::numeric_limits<T>::infinity();
78 for (std::size_t i = 0; i < N; ++i)
94 if (t0 > t1 || t1 < T{0})
100 template <
class T, std::
size_t N>
115 template <
class T, std::
size_t N>
136 return std::tuple<T, T>{t0, t1};
147 template <
class T, std::
size_t N>
150 return a.intersects(b);
162 template <
class T, std::
size_t N>
166 for (std::size_t i = 0; i < N; ++i)
183 template <
class T, std::
size_t N>
198 template <
class T, std::
size_t N>
201 return a.intersects(b);
constexpr int difference(T x, T y) noexcept
Returns the number of differing bits between two values, known as Hamming distance.
constexpr std::optional< T > intersection(const ray< T, N > &ray, const hyperplane< T, N > &hyperplane) noexcept
Ray-hyperplane intersection test.
constexpr T sqr_distance(const vector< T, N > &p0, const vector< T, N > &p1) noexcept
Calculates the square distance between two points.
constexpr vector< T, N > max(const vector< T, N > &x, const vector< T, N > &y)
Returns a vector containing the maximum elements of two vectors.
constexpr T sqr_length(const quaternion< T > &q) noexcept
Calculates the square length of a quaternion.
vector< T, N > sqrt(const vector< T, N > &x)
Takes the square root of each element.
constexpr T dot(const quaternion< T > &a, const quaternion< T > &b) noexcept
Calculates the dot product of two quaternions.
constexpr vector< T, N > min(const vector< T, N > &x, const vector< T, N > &y)
Returns a vector containing the minimum elements of two vectors.
vector_type normal
Hyperplane normal.
constexpr T distance(const vector_type &point) const noexcept
Calculates the signed distance from the hyperplane to a point.
n-dimensional axis-aligned rectangle.
vector_type max
Maximum extent of the hyperrectangle.
vector_type min
Minimum extent of the hyperrectangle.
vector_type center
Hypersphere center.
T radius
Hypersphere radius.
Half of a line proceeding from an initial point.
vector_type direction
Ray direction vector.
vector_type origin
Ray origin position.