Beispiel #1
0
        static vector3 slerp(vector3 start, vector3 end, T percent) {
            T dot = start.dot(end);
            dot = vector3::clamp(dot, -1.0f, 1.0f);

            T theta = acos(dot) * percent;
            vector3 relative = end - start*dot;
            relative.normalize();
            return ((start * cos(theta)) + (relative*sin(theta)));
        }
double get_rotation_angle(vector3<float> u, vector3<float> v) {
	u.normalize();
	v.normalize();
	double cosine_theta = u.dot(v);
	// domain of arccosine is [-1, 1]
	if (cosine_theta > 1) {
		cosine_theta = 1;
	}
	if (cosine_theta < -1) {
		cosine_theta = -1;
	}
	double angle = acos(cosine_theta);
	return angle;
}