glm_types.h
| File Path | engine/include/conjure/core/math/glm_types.h |
| API ↗ | Math |
The engine's vector, quaternion and matrix types are glm's. This is the single public header through which glm reaches the rest of the engine; glm is configured by the build with GLM_FORCE_RADIANS, GLM_FORCE_DEPTH_ZERO_TO_ONE, GLM_ENABLE_EXPERIMENTAL and GLM_FORCE_EXPLICIT_CTOR, so write vec3(0.0f), never vec3 value = 0.0f.
Structs
Type Aliases
ivec2
ivec3
ivec4
mat3
mat4
quat
uvec2
uvec3
uvec4
vec2
vec3
vec4
Functions
Public
detail::format_components
detail::format_componentstemplate <typename ComponentType, typename FormatContext> typename FormatContext::iterator format_components( const std::formatter<ComponentType> &componentFormatter, std::span<const ComponentType> components, FormatContext &context );Writes "(c0, c1, ...)" applying one component formatter (which already parsed the format spec) to every component.
nearly_equal
nearly_equal[[nodiscard]] inline bool nearly_equal(
const vec2 &a,
const vec2 &b,
f32 epsilon = EPSILON) noexcept;True when every component of a is within epsilon of the matching component of b.
[[nodiscard]] inline bool nearly_equal(
const vec3 &a,
const vec3 &b,
f32 epsilon = EPSILON) noexcept;True when every component of a is within epsilon of the matching component of b.
[[nodiscard]] inline bool nearly_equal(
const vec4 &a,
const vec4 &b,
f32 epsilon = EPSILON) noexcept;True when every component of a is within epsilon of the matching component of b.
[[nodiscard]] inline bool nearly_equal(
const quat &a,
const quat &b,
f32 epsilon = EPSILON) noexcept;True when every component of a is within epsilon of the matching component of b. Note that q and -q are different quaternions here although they encode the same rotation; use same_rotation() to compare rotations.
[[nodiscard]] inline bool nearly_equal(
const mat3 &a,
const mat3 &b,
f32 epsilon = EPSILON) noexcept;True when every element of a is within epsilon of the matching element of b.
[[nodiscard]] inline bool nearly_equal(
const mat4 &a,
const mat4 &b,
f32 epsilon = EPSILON) noexcept;True when every element of a is within epsilon of the matching element of b.
nearly_zero
nearly_zeroTrue when the vector's length is at most epsilon.
True when the vector's length is at most epsilon.
safe_normalize
safe_normalize[[nodiscard]] inline vec3 safe_normalize(
const vec3 &value,
const vec3 &fallback = vec3(0.0f, 0.0f, -1.0f)) noexcept;Normalises the vector, or returns fallback when its length is (nearly) zero. glm::normalize would produce NaN there.
[[nodiscard]] inline vec2 safe_normalize(
const vec2 &value,
const vec2 &fallback = vec2(1.0f, 0.0f)) noexcept;Normalises the vector, or returns fallback when its length is (nearly) zero.
same_rotation
same_rotation[[nodiscard]] inline bool same_rotation(
const quat &a,
const quat &b,
f32 epsilon = EPSILON) noexcept;True when two unit quaternions encode the same rotation within epsilon. q and -q are one rotation, so b is negated first when its dot product with a is negative; then every component of a must be within epsilon of the matching component of b, the tolerance nearly_equal() uses. In angles, for a small epsilon: two rotations up to 2 * epsilon radians apart compare equal, two more than about 4 * epsilon radians apart do not, and in between it depends on the axis. Float rounding of the inputs comes on top, so an epsilon near 1e-7 only accepts quaternions equal to the last bit or two.