CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
FloatingPoint.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include <cmath>
11#include <limits>
12#include <numeric>
13
14namespace CeresEngine::inline Math {
15
17 template<typename T> inline bool approxEquals(T a, T b, T tolerance = std::numeric_limits<T>::epsilon()) { return std::abs(b - a) <= tolerance; }
18
20 template<typename T> inline bool nearZero(T a, T tolerance = T(1e-8)) { return approxEquals<T>(a, T(0), tolerance); }
21
22} // namespace CeresEngine::inline Math
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Angle.hpp:20
bool approxEquals(T a, T b, T tolerance=std::numeric_limits< T >::epsilon())
Compare two doubles, using tolerance for inaccuracies.
Definition FloatingPoint.hpp:17
bool nearZero(T a, T tolerance=T(1e-8))
Return true iff a is almost zero.
Definition FloatingPoint.hpp:20