From 091bf9e418ffdcf36e1735ed78d544f3d1b86785 Mon Sep 17 00:00:00 2001 From: Mel Date: Mon, 5 Feb 2024 13:48:13 +0100 Subject: More precise collision detection (and less NaNs) --- src/Math/Functions.hpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/Math/Functions.hpp') diff --git a/src/Math/Functions.hpp b/src/Math/Functions.hpp index fd99c6d..0cda6bd 100644 --- a/src/Math/Functions.hpp +++ b/src/Math/Functions.hpp @@ -38,9 +38,16 @@ R sign(T x) { // III. Utility functions. +// Compares two floating point numbers for equality, with a given epsilon. template Bool floats_equal(T a, T b, Real epsilon = 0.0001f) { return std::abs(a - b) < epsilon; } +// Compares two floating point numbers for inequality, with a given epsilon. +template +Bool floats_less(T a, T b, Real epsilon = 0.0001f) { + return a < b - epsilon; +} + } \ No newline at end of file -- cgit 1.4.1