14#elif defined(__GNUC__) || defined(__GNUG__)
16#elif defined(_MSC_VER)
18#pragma warning(disable : 6001)
19#pragma warning(disable : 6287)
20#pragma warning(disable : 26495)
39 namespace numbers = ::std::numbers;
55 template <AnyVec Vector>
58 return incident - 2.0f *
dot(normal, incident) * normal;
76 template <AnyVec Vector>
79 auto const cos_theta =
dot(normal, incident);
80 auto const r_out_perp = eta * (incident - cos_theta * normal);
81 auto const r_out_parallel = -std::sqrt(std::abs(1.0f -
squared_length(r_out_perp))) * normal;
82 return r_out_perp + r_out_parallel;
97 template <
size_t size_x,
typename vector_type>
98 struct hash<
mal_math::vec<size_x, vector_type>> {
101 for (
auto const &e : v.data) {
102 seed ^= std::hash<vector_type>{}(e)+0x9e3779b9 + (seed << 6) + (seed >> 2);
98 struct hash<
mal_math::vec<size_x, vector_type>> {
…};
114 template <
size_t size_x,
size_t size_y,
typename matrix_type>
115 struct hash<
mal_math::mat<size_x, size_y, matrix_type>> {
118 for (
auto const &e : m.data) {
119 seed ^= std::hash<matrix_type>{}(e)+0x9e3779b9 + (seed << 6) + (seed >> 2);
115 struct hash<
mal_math::mat<size_x, size_y, matrix_type>> {
…};
131 template<
typename quaternion_type>
135 for (
auto const &e : q.data) {
136 seed ^= std::hash<quaternion_type>{}(e)+0x9e3779b9 + (seed << 6) + (seed >> 2);
142#if defined(__clang__)
144#elif defined(__GNUC__) || defined(__GNUG__)
146#elif defined(_MSC_VER)
Defines a templated bounding box class for 3D primitives.
Provides functionalities to represent and handle intersections in 3D space.
Provides matrix definitions tailored for various sizes and primitive types.
Contains mathematical utility functions and classes.
constexpr std::remove_const_t< typename T::type > squared_length(T const &vector) noexcept
Compute the squared length of the given vector.
constexpr T dot(qua< T > const &left, qua< U > const &right) noexcept
Computes the dot product of two quaternions.
constexpr vec< Vector::size, std::remove_const_t< typename Vector::type > > reflect(Vector const &normal, Vector const &incident) noexcept
Computes the reflection of an incident vector based on a surface's normal.
constexpr vec< Vector::size, std::remove_const_t< typename Vector::type > > refract(Vector const &normal, Vector const &incident, float eta) noexcept
Computes the refraction of a vector given an interface's normal and an index of refraction.
Provides the definition of the Plane structure and its associated operations.
Quaternion operations and related mathematical functions.
Provides functionality for random number generation and manipulation in vector spaces.
Contains the definition of the Ray class.
Defines the Sphere structure and its associated functionality.
Definition of matrix with dimensions rows x columns and type T
Represents a quaternion with primitive type T.
Definition of the mathematical vector with fixed size L and type T
constexpr size_t operator()(mal_math::mat< size_x, size_y, matrix_type > const &m) const noexcept
constexpr size_t operator()(mal_math::qua< quaternion_type > const &q) const noexcept
constexpr size_t operator()(mal_math::vec< size_x, vector_type > const &v) const noexcept
Defines the Triangle structure and methods for ray-triangle intersection.