2Quaterniond
my_slerp(Quaterniond v0, Quaterniond v1,
double t)
10 double dot = v0.dot(v1);
18 v1 = quaternion_negation(v1);
22 Quaterniond vdiff = quaternion_minus(v1, v0);
24 const double DOT_THRESHOLD = 0.9995;
25 if (dot > DOT_THRESHOLD)
30 Quaterniond result = scalar_product(vdiff, t);
36 double theta_0 = acos(dot);
37 double theta = theta_0 * t;
38 double sin_theta = sin(theta);
39 double sin_theta_0 = sin(theta_0);
42 cos(theta) - dot * sin_theta / sin_theta_0;
43 double s1 = sin_theta / sin_theta_0;
45 return quaternion_plus(scalar_product(v0, s0), scalar_product(v1, s1));