maliput
|
Functor to validate if a number is within [min, max] and considering assuming a tolerance.
This tolerance extends the range to be [min - tolerance, max + tolerance]. The functor not only validates that number is within the range, but also adapts it to be in the interval (min, max) where the difference between the close and open range is epsilon. This functor is motivated to wrap MALIPUT_VALIDATE() calls plus a std::clamp() to avoid throws for numerical errors.
#include <include/maliput/common/range_validator.h>
Public Member Functions | |
RangeValidator ()=delete | |
double | operator() (double s) const |
Evaluates whether s is in range or not. More... | |
Static Public Member Functions | |
static RangeValidator | GetRelativeEpsilonValidator (double min, double max, double tolerance, double epsilon) |
Creates a RangeValidator instance that uses a relative epsilon to validate the values. More... | |
static RangeValidator | GetAbsoluteEpsilonValidator (double min, double max, double tolerance, double epsilon) |
Creates a RangeValidator instance that uses a epsilon as the absolute epsilon to validate the values. More... | |
|
delete |
|
static |
Creates a RangeValidator instance that uses a epsilon
as the absolute epsilon to validate the values.
min | lower extreme of the range. |
max | upper extreme of the range. |
tolerance | is the range extension to be accepted. |
epsilon | is minimum difference that separates a number within the range to be distinct from range extremes (min and max ). |
maliput::common::assertion_error | When tolerance is non positive. |
maliput::common::assertion_error | When epsilon is not in [0, tolerance]. |
maliput::common::assertion_error | When min + epsilon > max or max - epsilon < min |
|
static |
Creates a RangeValidator instance that uses a relative epsilon to validate the values.
This relative epsilon is computed by multiplying epsilon
by the range.
min | lower extreme of the range. |
max | upper extreme of the range. |
tolerance | is the range extension to be accepted. |
epsilon | is the relative minimum difference that separates a number within range to be distinct from extremes. It is relative to the range. |
maliput::common::assertion_error | When tolerance is non positive. |
maliput::common::assertion_error | When epsilon is not in [0, tolerance]. |
maliput::common::assertion_error | When min + epsilon > max or max - epsilon < min |
Evaluates whether s
is in range or not.
s
when it is within the open range. If s
is equal to either range extremes or the difference to them is less or equal to tolerance, it returns the closest open range value. Otherwise, it maliput::common::assertion_error. |