How to inverse the distance formula in 3d?

101 Views Asked by At

I know how to output the distance between two points in space, but how can I reverse it? Instead of outputing a small value for somethink close I want to outpun a big value, and instead of a value big for somethink far I want to output a small value. I want them to range from 0 (even one if it is the only way) and a max value called a.

My reasons: I make a 3D pathfinding and I try to make a proximity area, further point from object will have a lower value.

1

There are 1 best solutions below

3
On BEST ANSWER

If the regular distance is $d$, try $d_{new}=a e^{-d}$. When $d=0$ you get $d_{new}=a$ and when $d\to\infty$ you get $d_{new}\to 0$. Other options would be inverse cotangent.

Edited I've changed $d'$ to $d_{new}$ to avoid confusing it with derivative