Calculate y-value from x
yv, idx = mpco:y(xv)
Finds the pair of x-values that xv
is within, and performs a linear slope conversion to calculate yv
.
Parameter | Type | Description |
---|---|---|
xv |
number | X value to convert |
Returns | Type | Description |
---|---|---|
yv |
number | Y value conversion |
idx |
integer | Index (effectively the insertion point of xv ) |
Returns nil
if xv
is out of bounds, or the uv
/ov
values if set.
Uses the tx
and ty
values passed when created float.mpc
e.g.
local m = float.mpc( {10,20,30}, {100,200,300} )
local y = m:y(15) -- > 150
local y = m:y(1) -- > nil
local y = m:y(301) -- > nil