import { inverseLerp } from "./inverseLerp.js";
import { lerp } from "./lerp.js";

/**
 * Returns linear remapping of {@link value} from source range [source_first, source_second] to target range [target_first, target_second]
 * This method is non-clamping, meaning that if your input is outside the source range - output will be outside the target range as well
 * @param {number} source_first
 * @param {number} source_second
 * @param {number} target_first
 * @param {number} target_second
 * @param {number} value
 * @return {number}
 */
export function remap(
    source_first, source_second,
    target_first, target_second,
    value
) {

    const relative = inverseLerp(source_first, source_second, value);

    return lerp(target_first, target_second, relative);
}
