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
|
Rotation matrix of angle theta around vector |
|
Quaternion for rotation of angle theta around vector |
|
Conjugate of quaternion |
|
Return identity quaternion |
|
Compute unit quaternion from last 3 values |
|
Return multiplicative inverse of quaternion q |
|
Return True is this is very nearly a unit quaternion |
|
Calculate quaternion corresponding to given rotation matrix |
|
Multiply two quaternions |
|
Returns True if q1 and q2 give near equivalent transforms |
|
Return norm of quaternion |
|
Convert quaternion to rotation of angle around axis |
|
Calculate rotation matrix corresponding to quaternion |
|
Apply transformation in quaternion q to vector v |