7 #ifndef LARCOREALG_COREUTILS_NUMERICUTILS_H 8 #define LARCOREALG_COREUTILS_NUMERICUTILS_H 11 #include <type_traits> 68 template <
typename A,
typename B>
69 constexpr
auto absDiff(A
const& a, B
const& b)
71 static_assert(std::is_same<std::decay_t<A>, std::decay_t<B>>{},
72 "Arguments of util::absDiff() have to be of the same type.");
73 return (b > a) ? (b - a) : (a - b);
79 #endif // LARCOREALG_COREUTILS_NUMERICUTILS_H
bool PointWithinSegments(double A_start_x, double A_start_y, double A_end_x, double A_end_y, double B_start_x, double B_start_y, double B_end_x, double B_end_y, double x, double y)
Returns whether x and y are within both specified ranges (A and B).
LArSoft utility namespace.
bool ValueInRange(double value, double min, double max)
Returns whether a value is within the specified range.
constexpr auto absDiff(A const &a, B const &b)
Returns the absolute value of the difference between two values.