blob: 24d0f3a3cbd4e12ca7cb38c0709ff667e3bafab5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
// test_math_helpers.h - Math utilities for test code
// Common floating-point comparison helpers
#pragma once
#include "util/mini_math.h"
#include <cmath>
// Floating-point comparison with epsilon tolerance
inline bool test_near(float a, float b, float epsilon = 1e-6f) {
return fabs(a - b) < epsilon;
}
// Vector comparison
inline bool test_near_vec3(vec3 a, vec3 b, float epsilon = 1e-6f) {
return test_near(a.x, b.x, epsilon) && test_near(a.y, b.y, epsilon) &&
test_near(a.z, b.z, epsilon);
}
|