adapnex::core::map

Maps a number linearly from one range to another.

Synopsis

Declared in <adapnex/core/util.h>

template<typename T>
T
map(
    T x,
    T in_min,
    T in_max,
    T out_min,
    T out_max);

Description

Does not constrain values to the range, as out‐of‐range values are sometimes intended and useful. Use std::clamp() if clamping is desired.

Return Value

The mapped value in the target range.

Parameters

Name Description

x

The input value to be mapped.

in_min

The lower bound of the value’s current range.

in_max

The upper bound of the value’s current range.

out_min

The lower bound of the value’s target range.

out_max

The upper bound of the value’s target range.

Created with MrDocs