I have some knobs with an internal value of $0$ to $1$. These represent a value in a range, like $1$ to $1000$.
Case in point, I would like to be able to change the scale/growth of the display value. For instance, the display value with linear growth:
ling(x) = min + (max-min) * x
Where $x$ is between $0$ and $1$.
Similarly with exponential growth:
expg(x) = min * (max/min)^x
Is there a similar rule/formula with logarithmic properties?
edit:
Okay i've been trying out some different things. Originally i worked with this:
logg(x) = (max - min)/log(max - min + 1) * log((max - min) * x + 1) + min
But i realized the slope was not the inverse of the expg function (which should be an identity of the logarithmic function?). I decided to mirror the expg(x) function instead:
lelogg(x) = ling(1 - x) - expg(1 - x) + ling(x)
which seems perfect:
but it begs the question, which of these graphs has true logarithmic / exponential growth?
Best Answer
ling(x)
is a linear function as it corresponds to $y=a+bx$ if you setmin=a
andmax=a+b
expg(x)
is an exponential function as it corresponds to $y=ae^{bx}$ if you setmin=a
andmax=a*exp(b)
logg(x)
is almost a logarithmic function of the form $y=a\log(x)+b$ except that you havelog((max - min) * x + 1)
whenlog((max - min) * x)
would be better, and in general the whole expression could be simplerlelogg(x)
is not a logarithmic function, but instead the difference between a constant and a negative exponential function, so is bounded above, unlike a logarithmic function. Note thatling(1 - x) + ling(x)
is the same asmax+min