MPMA Framework 0.4
|
00001 00002 //Luke Lenhart, 2004-2007 00003 //See /docs/License.txt for details on how this code may be used. 00004 00005 #pragma once 00006 00007 #include "../base/Setup.h" 00008 00009 #ifdef MPMA_COMPILE_GEO 00010 00011 #include "Geo.h" 00012 #include <vector> 00013 00014 namespace GEO 00015 { 00017 template <typename T> inline T Lerp(const T &e0, const T &e1, float w) 00018 { 00019 return (1.0f-w)*e0 + w*e1; 00020 } 00021 00023 template <typename T> inline T Bilerp(const T &e00, const T &e10, const T &e01, const T &e11, float x, float y) 00024 { 00025 return Lerp( Lerp(e00,e10,x), Lerp(e01,e11,x), y); 00026 } 00027 00029 template <typename T> inline T AdjustTowardsTarget(const T ¤t, const T &target, const T &change) 00030 { 00031 T newVal=current; 00032 if (std::fabs(target-current)<change) 00033 { 00034 newVal=target; 00035 } 00036 else 00037 { 00038 if (target<current) 00039 newVal-=change; 00040 else 00041 newVal+=change; 00042 } 00043 return newVal; 00044 } 00045 00046 }; //namespace GEO 00047 00048 #endif //#ifdef MPMA_COMPILE_GEO