Answer the question
In order to leave comments, you need to log in
How to write a function for converting values from one scale to another?
There is a range of values from 0.0 to 1.0, conditionally a basic scale of values (subjectively, this is engine speed).
It is necessary to convert values from this range to the values of another scale, in which 2 values are known, corresponding to the values of the base scale 0.0, 0.2 and 1.0. We need a function that will allow us to calculate all intermediate values of the new scale, from the known values of the base scale. And values of 0 of the base scale are always 0 of the final scale.
A linear function will do, and I assume that there will be 2 of them, under sections 0-0.2 and 0.2-1.0.
I hope I explained it clearly, an example:
there are values of the final scale 0.0=0 (zeros are always equal for the scales), 0.2 = 1000 and 1.0 = 6000 . Bold marked the input values.
Answer the question
In order to leave comments, you need to log in
On the first interval
y=x*1000;
On the second
y=1000+(x-0.2)*(6000-1000)
Through 3 points you can draw a parabola, then you do not have to work with ranges.
Look at Lagrange interpolation for example.
https://ru.wikipedia.org/wiki/%D0%98%D0%BD%D1%82%D...
For your case Y =1250*X*(X+3.8)
X - This is the original
Y scale - This is the new scale
Y(0) = 0
Y(0.2) = 1000
Y(1) = 6000
This is called in school - to build the equation of a straight line from two points.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question