lerp()
我的类模板中有一个静态成员函数AnimCurve
,我想专门针对四元数,这样:
template<>
inline Quatf AnimCurve<Quatf>::lerp(
const Quatf& start,
const Quatf& end,
float time
)
{
return start.slerp(time, end);
}
但是,这还不够通用,因为也可以使用Quatd
. 是否可以编写一个对两者都适用的函数,因为Quatf
和Quatd
都是 的类型定义Quaternion<T>
?
这是 的当前定义AnimCurve
:
template< typename T >
class AnimCurve {
public:
AnimCurve() {}
void addKeyframe(float time, T value);
T getvalue(float time) const;
private:
static inline T lerp( const T& start, const T& end, float time );
std::map<float, T> mKeyframes;
};