Search code examples
javascriptmathfloating-pointlogarithmcurve

How to calculate the curve of a linear floating point number in Javascript?


How do I calculate a curve of a linear floating point number (0 to 1) and get another floating point number as a result? What I want is up until the half (0..0.5), to be inversed logarithmic and high than that to be logarithmic like a curve according to the given linear value.


Solution

  • So, what you are looking for is a function to do:

    double x, y;
    y = 1.0 / log(x) {x = 0 .. 0.5}
        log(x)     {x = 0.5 .. 1}
    

    ??

    or:

    y = exp(x) {x = 0 .. 0.5}
    

    ??