Map#
Defined in namespace hal
#include <libhal-util/map.hpp>
- group Map
Functions
-
constexpr float map(float p_target, std::pair<float, float> p_input_range, std::pair<float, float> p_output_range)#
Map an target value [x] from an input range [a,b] to an output range [c,d].
Another term for this is an affine transformation which follows this equation:
For example:/ d - c \ y = (x - a) * | --------| + c \ b - a /
let x = 5.0 let input_range = [0.0, 10.0] let output_range = [100.0, 200.0] The result will be 150.0
- Parameters:
p_target – - target value within p_input_range to be mapped to the output range.
p_input_range – - the input range of p_target
p_output_range – - the output range to map p_target to
- Returns:
constexpr float - value mapped from input range to the output range. The output is clamped to the output range.
-
constexpr float map(float p_target, std::pair<float, float> p_input_range, std::pair<float, float> p_output_range)#