NiBabel

Access a cacophony of neuro-imaging file formats

Previous topic

nibabel.orientations.ornt2axcodes

Next topic

nibabel.quaternions.angle_axis2mat

This Page

Reggie -- the one

nibabel.quaternionsΒΆ

Functions to operate on, or return, quaternions.

The module also includes functions for the closely related angle, axis pair as a specification for rotation.

Quaternions here consist of 4 values w, x, y, z, where w is the real (scalar) part, and x, y, z are the complex (vector) part.

Note - rotation matrices here apply to column vectors, that is, they are applied on the left of the vector. For example:

>>> import numpy as np
>>> q = [0, 1, 0, 0] # 180 degree rotation around axis 0
>>> M = quat2mat(q) # from this module
>>> vec = np.array([1, 2, 3]).reshape((3,1)) # column vector
>>> tvec = np.dot(M, vec)

Functions

angle_axis2mat(theta, vector[, is_normalized]) Rotation matrix of angle theta around vector
angle_axis2quat(theta, vector[, is_normalized]) Quaternion for rotation of angle theta around vector
conjugate(q) Conjugate of quaternion
eye() Return identity quaternion
fillpositive(xyz[, w2_thresh]) Compute unit quaternion from last 3 values
inverse(q) Return multiplicative inverse of quaternion q
isunit(q) Return True is this is very nearly a unit quaternion
mat2quat(M) Calculate quaternion corresponding to given rotation matrix
mult(q1, q2) Multiply two quaternions
nearly_equivalent(q1, q2[, rtol, atol]) Returns True if q1 and q2 give near equivalent transforms
norm(q) Return norm of quaternion
quat2angle_axis(quat[, identity_thresh]) Convert quaternion to rotation of angle around axis
quat2mat(q) Calculate rotation matrix corresponding to quaternion
rotate_vector(v, q) Apply transformation in quaternion q to vector v