# Module: tfg.math.interpolation.slerp

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/graphics/blob/master/tensorflow_graphics/math/interpolation/slerp.py) |

Tensorflow.graphics 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.

## Classes

[`class InterpolationType`](https://www.tensorflow.org/graphics/api_docs/python/tfg/math/interpolation/slerp/InterpolationType): Defines interpolation methods for slerp module.

## Functions

[`interpolate(...)`](https://www.tensorflow.org/graphics/api_docs/python/tfg/math/interpolation/slerp/interpolate): Applies slerp to vectors or quaternions.

[`interpolate_with_weights(...)`](https://www.tensorflow.org/graphics/api_docs/python/tfg/math/interpolation/slerp/interpolate_with_weights): Interpolates vectors by taking their weighted sum.

[`quaternion_weights(...)`](https://www.tensorflow.org/graphics/api_docs/python/tfg/math/interpolation/slerp/quaternion_weights): Calculates slerp weights for two normalized quaternions.

[`vector_weights(...)`](https://www.tensorflow.org/graphics/api_docs/python/tfg/math/interpolation/slerp/vector_weights): Spherical linear interpolation (slerp) between two unnormalized vectors.