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!

  • $\begingroup$ Hint: $$x+\frac y{15}=1.$$ You can easily draw $x$ or $y$ in terms of the other variable. $\endgroup$ – Yves Daoust Apr 22 '17 at 9:34
  • $\begingroup$ Ahh! So presumably $x = 1 - \frac{y}{15}$ to solve for $x$, etc... That does the trick, and so simple too! I feel like such an idiot. I will take this as an opportunity to humble myself. Thank you very much! $\endgroup$ – Christopher James Apr 22 '17 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.