Skip to main content
The Deno 2 Release Candidate is here
Learn more
method MathUtil.prototype.mapToRange
import { MathUtil } from "https://deno.land/x/sptaki@1.2.0/utils/MathUtil.d.ts";

Map a value from an input range to an output range linearly

Example: a_min = 0; a_max=1; b_min = 1; b_max=3; MathUtil.mapToRange(0.5, a_min, a_max, b_min, b_max) // returns 2

Parameters

x: number

The value from input range to be mapped to output range

minIn: number

min of input range

maxIn: number

max of input range

minOut: number

min of output range

maxOut: number

max of outout range

Returns

number

the result of the mapping