mal-math
C++20 mathematics library.
All Classes Namespaces Files Functions Variables Typedefs Concepts
intersection.hpp
Go to the documentation of this file.
1
37#pragma once
38#include "../math.hpp"
39
40#pragma warning(push)
41#pragma warning(disable : 26495)
42
43namespace mal_math
44{
53 {
54 float t;
57
58 constexpr Intersection() = default;
59 constexpr Intersection(Intersection const &) = default;
60 constexpr Intersection &operator=(Intersection const &) = default;
61 constexpr Intersection(Intersection &&) = default;
62 constexpr Intersection &operator=(Intersection &&) = default;
63
69 constexpr void reset() { t = std::numeric_limits<float>::infinity(); }
70
77 inline bool exists() const { return std::isfinite(t); }
78
84 static constexpr Intersection infinite()
85 {
86 Intersection inf;
87 inf.reset();
88 return inf;
89 }
90 };
91} // namespace mal_math
92
93#pragma warning(pop)
Provides various mathematical utilities, vector operations, and custom hash specializations.
Contains mathematical utility functions and classes.
Represents the data of a ray's intersection with an object.
constexpr Intersection()=default
float t
The intersection parameter.
constexpr Intersection(Intersection const &)=default
constexpr Intersection & operator=(Intersection &&)=default
constexpr Intersection & operator=(Intersection const &)=default
bool exists() const
Determines if the intersection exists based on the value of t.
vec3 point
The 3D point of intersection.
constexpr Intersection(Intersection &&)=default
static constexpr Intersection infinite()
Creates and returns an intersection with t set to infinity.
vec3 normal
The 3D normal at the point of intersection.
constexpr void reset()
Resets the intersection data.