Changeset 1833


Ignore:
Timestamp:
Aug 29, 2012, 10:27:53 PM (7 years ago)
Author:
touky
Message:
 
Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lol/math/math.h

    r1513 r1833  
    6565}
    6666
     67static inline double lerp(double const &a, double const &b, double const &x)
     68{
     69        return a + (b - a) * x;
     70}
     71static inline float lerp(float const &a, float const &b, float const &x)
     72{
     73        return a + (b - a) * x;
     74}
     75
     76
    6777/* These accelerated functions will be merged into the above, one day */
    6878double lol_sin(double);
  • trunk/src/lol/math/vector.h

    r1807 r1833  
    12301230            ret += a[n] * b[n]; \
    12311231        return ret; \
     1232    } \
     1233    tprefix \
     1234    inline tname<tf> lerp(tname<t1> const &a, tname<t2> const &b, tf x) \
     1235    { \
     1236        tname<tf> ret; \
     1237        for (size_t n = 0; n < sizeof(a) / sizeof(t1); n++) \
     1238            ret[n] = a[n] + (a[n] - b[n]) * x; \
     1239        return ret; \
    12321240    }
    12331241
  • trunk/src/numeric.h

    r1513 r1833  
    5353}
    5454
     55//Lerp for float
     56template <typename T1, typename T2, typename Tf> static inline T1 damp(const T1 &a, const T2 &b, const Tf &x, const Tf &dt)
     57{
     58        if (dt <= .0f)
     59                return a;
     60    return lol::lerp(a, b, dt / (dt + x));
     61}
     62
    5563} /* namespace lol */
    5664
Note: See TracChangeset for help on using the changeset viewer.