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

Module: tfg.geometry.transformation.quaternion

This module implements TensorFlow quaternion utility functions.

A quaternion is written as

$$q = xi + yj + zk + w$$

, where


forms the three bases of the imaginary part. The functions implemented in this file use the Hamilton convention where

$$i^2 = j^2 = k^2 = ijk = -1$$

. A quaternion is stored in a 4-D vector

$$[x, y, z, w]^T$$


More details about Hamiltonian quaternions can be found on this page.

$$x^2 + y^2 + z^2 + w^2 = 1$$



class range: range(stop) -> range object


between_two_vectors_3d(...): Computes quaternion over the shortest arc between two vectors.

conjugate(...): Computes the conjugate of a quaternion.

from_axis_angle(...): Converts an axis-angle representation to a quaternion.

from_euler(...): Converts an Euler angle representation to a quaternion.

from_euler_with_small_angles_approximation(...): Converts small Euler angles to quaternions.

from_rotation_matrix(...): Converts a rotation matrix representation to a quaternion.

inverse(...): Computes the inverse of a quaternion.

is_normalized(...): Determines if quaternion is normalized quaternion or not.

multiply(...): Multiplies two quaternions.

normalize(...): Normalizes a quaternion.

normalized_random_uniform(...): Random normalized quaternion following a uniform distribution law on SO(3).

normalized_random_uniform_initializer(...): Random unit quaternion initializer.

relative_angle(...): Computes the unsigned relative rotation angle between 2 unit quaternions.

rotate(...): Rotates a point using a quaternion.