This is a math problem, but computers help to solve it using linear forumla (as suggested by @cmgchess in comments):
var x1 = 10;
var x2 = 100;
var y1 = 2;
var y2 = 15;
var x_inp = 6;
// var y_out = ? ? ?
var calcY = getLinearFunction(x1, y1, x2, y2);
console.log(calcY(6))
function getLinearFunction(x1, y1, x2, y2) {
var slope = (y2 - y1) / (x2 - x1);
return function(x) {
return slope * (x - x1) + y1;
}
}
0
solved Fromula to find value in y axis for given value in x axis [closed]