return a + t*(b-a);
}
+static inline double vg_lerp( double a, double b, double t )
+{
+ return a + t*(b-a);
+}
+
+/* correctly lerp around circular period -pi -> pi */
+static float vg_alerpf( float a, float b, float t )
+{
+ float d = fmodf( b-a, VG_TAUf ),
+ s = fmodf( 2.0f*d, VG_TAUf ) - d;
+ return a + s*t;
+}
+
static inline void v3_lerp( v3f a, v3f b, float t, v3f d )
{
d[0] = a[0] + t*(b[0]-a[0]);
static inline void q_nlerp( v4f a, v4f b, float t, v4f d )
{
- v4_lerp( a, b, t, d );
+ if( v4_dot(a,b) < 0.0f )
+ {
+ v4_muls( b, -1.0f, d );
+ v4_lerp( a, d, t, d );
+ }
+ else
+ v4_lerp( a, b, t, d );
+
q_normalize( d );
}