Module: xrd.rotations

20 Functions

hexrd.xrd.rotations.arccosSafe(temp)[source]

Protect against numbers slightly larger than 1 in magnitude due to round-off

hexrd.xrd.rotations.fixQuat(q)[source]

flip to positive q0 and normalize

hexrd.xrd.rotations.invertQuat(q)[source]

silly little routine for inverting a quaternion

hexrd.xrd.rotations.misorientation(q1, q2, *args)[source]

sym is a tuple (crystal_symmetry, *sample_symmetry) generally coded, may split up special cases for no symmetry or crystal/sample only...

hexrd.xrd.rotations.quatProduct(q1, q2)[source]

Product of two unit quaternions.

qp = quatProduct(q2, q1)

q2, q1 are 4 x n, arrays whose columns are
quaternion parameters
qp is 4 x n, an array whose columns are the
quaternion parameters of the product; the first component of qp is nonnegative

If R(q) is the rotation corresponding to the quaternion parameters q, then

R(qp) = R(q2) R(q1)

hexrd.xrd.rotations.quatProductMatrix(quats, mult='right')[source]

Form 4 x 4 arrays to perform the quaternion product

USAGE
qmats = quatProductMatrix(quats, mult=’right’)
INPUTS
  1. quats is (4, n), a numpy ndarray array of n quaternions horizontally concatenated

  2. mult is a keyword arg, either ‘left’ or ‘right’, denoting the sense of the multiplication:

    / quatProductMatrix(h, mult=’right’) * q

    q * h –> <

    quatProductMatrix(q, mult=’left’) * h

OUTPUTS
  1. qmats is (n, 4, 4), the left or right quaternion product operator
NOTES
*) This function is intended to replace a cross-product based
routine for products of quaternions with large arrays of quaternions (e.g. applying symmetries to a large set of orientations).
hexrd.xrd.rotations.quatOfAngleAxis(angle, rotaxis)[source]

make an hstacked array of quaternions from arrays of angle/axis pairs

hexrd.xrd.rotations.quatOfExpMap(expMap)[source]
hexrd.xrd.rotations.quatOfRotMat(R)[source]
hexrd.xrd.rotations.rotMatOfExpMap_opt(expMap)[source]

Optimized version of rotMatOfExpMap

hexrd.xrd.rotations.rotMatOfExpMap_orig(expMap)[source]

Original rotMatOfExpMap, used for comparison to optimized version

hexrd.xrd.rotations.rotMatOfQuat(quat)[source]

Take an array of n quats (numpy ndarray, 4 x n) and generate an array of rotation matrices (n x 3 x 3)

Uses the truncated series expansion for the exponential map; didvide-by-zero is checked using the global ‘tinyRotAng’

hexrd.xrd.rotations.angleAxisOfRotMat(R)[source]
hexrd.xrd.rotations.distanceToFiber(c, s, q, qsym, **kwargs)[source]
discreteFiber(c, s, B=array([[ 1., 0., 0.],
[ 0., 1., 0.],
[ 0., 0., 1.]]), ndiv=120, invert=False, csym=None, ssym=None)
hexrd.xrd.rotations.mapAngle(ang, *args, **kwargs)[source]

Utility routine to map an angle into a specified period

hexrd.xrd.rotations.angularDifference_orig(angList0, angList1, units='radians')[source]

Do the proper (acute) angular difference in the context of a branch cut.

*) Default angular range in the code is [-pi, pi] *) ... maybe more efficient not to vectorize?

hexrd.xrd.rotations.angularDifference_opt(angList0, angList1, units='radians')[source]

Do the proper (acute) angular difference in the context of a branch cut.

*) Default angular range in the code is [-pi, pi]

hexrd.xrd.rotations.printTestName(num, name)[source]
hexrd.xrd.rotations.testRotMatOfExpMap(numpts)[source]

Test rotation matrix from axial vector