cocos2d/external/chipmunk/include/chipmunk/cpVect.h
static inline cpVect
cpvslerp(const cpVect v1, const cpVect v2, const cpFloat t)
{
	cpFloat dot = cpvdot(cpvnormalize(v1), cpvnormalize(v2));
	cpFloat omega = cpfacos(cpfclamp(dot, -1.0f, 1.0f));
	
	if(omega < 1e-3){
		// If the angle between two vectors is very small, lerp instead to avoid precision issues.
		return cpvlerp(v1, v2, t);
	} else {
		cpFloat denom = 1.0f/cpfsin(omega);
		return cpvadd(cpvmult(v1, cpfsin((1.0f - t)*omega)*denom), cpvmult(v2, cpfsin(t*omega)*denom));
	}
}
/// Spherical linearly interpolate between v1 and v2.
Spherical linearly interpolate between v1 and v2.
Spherical linearly interpolate between v1 and v2 .
static inline cpVect
cpvslerp(const cpVect v1, const cpVect v2, const cpFloat t)
{
	cpFloat dot = cpvdot(cpvnormalize(v1), cpvnormalize(v2));
	cpFloat omega = cpfacos(cpfclamp(dot, -1.0f, 1.0f));
	if(omega < 1e-3){
		return cpvlerp(v1, v2, t);
	} else {
		cpFloat denom = 1.0f/cpfsin(omega);
		return cpvadd(cpvmult(v1, cpfsin((1.0f - t)*omega)*denom), cpvmult(v2, cpfsin(t*omega)*denom));
	}
}
static inline cpVect cpvslerp ( const cpVect v1 , const cpVect v2 , const cpFloat t ) { cpFloat dot = cpvdot ( cpvnormalize ( v1 ) , cpvnormalize ( v2 ) ) ; cpFloat omega = cpfacos ( cpfclamp ( dot , -1.0f , 1.0f ) ) ; if ( omega < 1e-3 ) { return cpvlerp ( v1 , v2 , t ) ; } else { cpFloat denom = 1.0f / cpfsin ( omega ) ; return cpvadd ( cpvmult ( v1 , cpfsin ( ( 1.0f - t ) * omega ) * denom ) , cpvmult ( v2 , cpfsin ( t * omega ) * denom ) ) ; } }
Spherical linearly interpolate between v1 and v2.
Spherical linearly interpolate between v1 and v2 .
// If the angle between two vectors is very small, lerp instead to avoid precision issues.