0
$\begingroup$

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.

$\endgroup$

2 Answers 2

0
$\begingroup$

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

$\endgroup$
1
  • 1
    $\begingroup$ Beautiful! Thank you. $\endgroup$
    – Slippers
    Commented Apr 21, 2018 at 22:32
0
$\begingroup$

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.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .