我有“scaledValue”,我想找到“价值”,我可以反转此功能吗?
但似乎不可能? (接受相似的值)
var priceBound = [0, 10000000];
var priceCurves = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.2, 1.4, 1.6, 1.8, 5, 35, 70, 100];
function calcScaledPrice(Value) {
var currentValue = Value;
var currentFixed = Value - priceBound[0];
var fixedBound = priceBound[1] - priceBound[0];
var currentPercent = Math.round((currentFixed/fixedBound) * 20);
var currentScale = priceCurves[currentPercent];
var scaledValue = Math.round(currentValue * (currentScale/100));
return scaledValue;
}
你想把它作为一个等式来解决吗?或将console.log(值)足够? –
如果它是一种双射,它是可逆的:如果它是一对一的并且在上面。 –
如果'scaledValue = currentValue * currentScale/100'则解决* currentValue *:'currentValue = scaledValue * 100/currentScale'。 – RobG