What's the simplest way to calculate an inverse relationship between two numbers?

233 Views Asked by At

TL;DR: I have two shifting variables in an inverse relationship, $x$ and $y$. I want to be able to determine either value, given the other value. $x$ has a scope of $0$ to $1$, and $y$ has a scope of $0$ to infinity. As $y$ approaches 15, $x$ approaches 0. When $y < 15$ and approaches $0$, $x$ approaches $1$. What formula will determine the value of $x$, given the inverse relationship and upper bounds on $y$?


I'm trying to come up with a formula to determine the new value of $x$, where $x$ is any number between $0.000$ and $1.000$, and is inversely related to another value, $y$, which is any number between $0.000$ and infinity. $y == 15.000$ is the upper bounds on $x$'s inverse relationship to $y$.

For example:

  • When $y == 15$, $x == 0$

  • As $y$ approaches $0.000$, $x$ approaches $1.000$

  • As $y$ approaches $15.000$, $x$ approaches $0.000$

  • When $y$ reaches $0.000$, $x$ reaches $1.000$

  • When $x$ reaches $0.000$, $y$ reaches $15.000$

  • And $y$ can be any value over $15.000$

As a real world example: as wind speed ($y$) approaches 15 m/s, fog density ($x$) decreases, and vice versa. When wind speed ($y$) is 15 m/s or higher, fog density ($x$) is always 0 or null.

I put together a quick graphical representation of the relationship that might make the above easier to parse. $x$ has been set to $10$ for readability.

I had a look through another question and answer that seems directly related to this one, but I couldn't quite parse the solution, and was hoping there was a simpler solution I could use in the context of a game engine script dealing with wind displacing fog.

Any help would be greatly appreciated! Please forgive me in advance if my question is poorly worded!