Save the date! Google I/O returns May 18-20 Register now

Module: tfg.math.interpolation.slerp slerp interpolation module.

Spherical linear interpolation (slerp) is defined for both quaternions and for regular M-D vectors, and act slightly differently because of inherent ambiguity of quaternions. This module has two functions returning the interpolation weights for quaternions (quaternion_weights) and for vectors (vector_weights), which can then be used in a weighted sum to calculate the final interpolated quaternions and vectors. A helper interpolate function is also provided.

The main differences between two methods are: vector_weights: can get any M-D tensor as input, does not expect normalized vectors as input, returns unnormalized outputs (in general) for unnormalized inputs.

quaternion_weights: expects M-D tensors with a last dimension of 4, assumes normalized input, checks for ambiguity by looking at the angle between quaternions, returns normalized quaternions naturally.


class InterpolationType: Defines interpolation methods for slerp module.


interpolate(...): Applies slerp to vectors or quaternions.

interpolate_with_weights(...): Interpolates vectors by taking their weighted sum.

quaternion_weights(...): Calculates slerp weights for two normalized quaternions.

vector_weights(...): Spherical linear interpolation (slerp) between two unnormalized vectors.