Skip to main content

Mathf.InverseLerp(number a, number b, number value)

Calculates the linear parameter t that produces the interpolant value within the range [a, b].

Parameters:

NameTypeDescription
anumberStart value.
bnumberEnd value.
valuenumberValue between start and end.

Returns:

typeDescription
numberPercentage of value between start and end.

Usage

---@type number
local a;

---@type number
local b;

---@type number
local value;


local val0 = Mathf:InverseLerp(a, b, value)

Extra Detail

The a and b values define the start and end of the line. Value is a location between a and b. Subtract a from both a and b and value to make a', b' and value'. This makes a' to be zero and b' and value' to be reduced. Finally divide value' by b'. This gives the InverseLerp amount.