Logarithmically decreasing output from linearly increasing input.

301 Views Asked by At

I am trying to create a logarithmically decreasing output from a linearly increasing input. Say that I have two graphs, one representing the input and the other representing the output, I have a linear one (the input) that starts at zero and increases linearly to $255$, while the other one (the output) will need to start at $255$ and decrease fast before evening out and ending at zero.

This is to be used for filtering joystick controller input. I am looking for a function that looks something like this: $f(x) = 255 - Kx$, where $K$ is the value that I'm struggling to find.

I have been scratching my head for a while and would appreciate some guidance.

2

There are 2 best solutions below

1
On BEST ANSWER

What do you think about $f(x) = 255 - a \cdot \log(x+1)$ where $a = 255/\log(256) \approx 46$?

0
On

Decreasing fast and evening out sounds more like an exponential. You might be interested in

$$f(x) = 255e^{-kx}$$

For some very small positive value of k.