GeometriCS/utils/Utils.cs
Zdeněk Borovec ad0599f481 Decided on architecture
A sizeable commit, I know, but I wanted to try and write a few aspects before deciding to settle on a system. This one seems to be fine so far. But I would still not rely on it not changing.
2024-04-18 01:29:47 +02:00

22 lines
823 B
C#

namespace GeometriCS
{
/// <summary>
/// Common utilities throughout the library.
/// </summary>
internal static class Utils
{
/// <summary>
/// Default precision for double equality comparison.
/// </summary>
private const double DOUBLEPRECISION = 1E-5;
/// <summary>
/// Tests whether the difference between two doubles is within a given limit.
/// </summary>
/// <param name="a">First value to test.</param>
/// <param name="b">Second value to test.</param>
/// <param name="prec">Maximum allowed difference.</param>
/// <returns>Do the values almost equal each other.</returns>
public static bool DoubleEquals(double a, double b, double prec = DOUBLEPRECISION) => Math.Abs(a - b) <= prec;
}
}