Module: orientations

8 Classes

class hexrd.orientations.RotationParameterization(args)[source]

template for rotation parameterization class

__init__(args)[source]
toMatrix()[source]

use matrix as common representation all classes should have a constructor that works using this

** Construct [C] matrix (Kocks convention) ** {a} = [C] {a} ** sm cr
class hexrd.orientations.RotInv(*args)[source]

Bases: hexrd.orientations.RotationParameterization

rotation invariants

__init__(*args)[source]
class hexrd.orientations.CanovaEuler(*args)[source]

Bases: hexrd.orientations.RotationParameterization

__init__(*args)[source]
class hexrd.orientations.KocksEuler(*args)[source]

Bases: hexrd.orientations.RotationParameterization

Kocks Euler angles see equation 6 page 65 of koc-tom-wen-98a (Kocks, Tome, & Wenk; Texture and Anisotropy)

__init__(*args)[source]
toBunge()[source]

trusting Table 1a of koc-tom-wen-98a (Kocks, Tome, & Wenk; Texture and Anisotropy)

class hexrd.orientations.BungeEuler(*args)[source]

Bases: hexrd.orientations.RotationParameterization

Bunge Euler angles see koc-tom-wen-98a (Kocks, Tome, & Wenk; Texture and Anisotropy)

__init__(*args)[source]
toKocks()[source]

trusting Table 1a of koc-tom-wen-98a (Kocks, Tome, & Wenk; Texture and Anisotropy)

class hexrd.orientations.Quat(*args)[source]

Bases: hexrd.orientations.RotationParameterization

quaternions, normalized; parameterization of SO(3); do not bother making unique (is 2-to-1)

__init__(*args)[source]
T()[source]

return transposed quaternion

static getRandQuat(n=1)[source]

sample uniform orientation distribution to get quaternion parameters

misorAng(other)[source]

compute the misorientation angle, in radians, in [0,2*pi]

normalize()[source]

normalize the quaternion

static normalizeQuat(q)[source]

normalize in place

normalized()[source]

return normalize quaternion

transpose()[source]

transpose the quaternion in place; retains metadata

transposed()[source]

return transposed quaternion

class hexrd.orientations.SymmGroup(*args)[source]

symmetry group

__init__(*args)[source]
findDistinct(qList)[source]

given a list of quaternions, find those which are distinct under the symmetry group

class hexrd.orientations.Fiber(latVec, recipVec)[source]

Like John Edmiston’s MakeFiber class, but with the implementation more tightly coupled to the rest of the code base

__init__(latVec, recipVec)[source]
distBetweenFibers(other)[source]

Compute the distance between two fibers using the polar decomposition of the projection operator taking one geodesic plane to the other. input: instance of MakeFiber class output: (max_eigenvalue, Rotation at max_eigenvalue), intersecting fibers would have max_eigenvalue ~ 1. Rotation at max_eigenvalue would be the ‘closest’ Rotation which would relate the two fibers.

25 Functions

hexrd.orientations.arccosSafe(temp)[source]
hexrd.orientations.orthogonalize(rMatIn)[source]
hexrd.orientations.traceToAng(tr)[source]

given trace of a rotation matrix find the angle or rotation

hexrd.orientations.matToCanova(r)[source]
hexrd.orientations.invToRodr(inv)[source]

do not check for divide-by-zero

hexrd.orientations.rodrToInv(rodr)[source]

do not check for divide-by-zero

hexrd.orientations.rodrToQuat(rodr)[source]
hexrd.orientations.invToM(theta, n0, n1, n2)[source]
hexrd.orientations.invToQuat(inv)[source]
hexrd.orientations.bungeToMat(euler)[source]
hexrd.orientations.matToQuat(r)[source]

based on Spurrier’s algorithm for quaternion extraction, as described in cite{sim-vuq-85a}

returns a 4-vector, not a Quat instance

BibTeX: @TechReport{sim-vuq-85a, author = {J. C. Simo and L. {Vu Quoc}}, title = {Three dimensional finite strain rod model part

{II}: computational aspects, Memorandum No. {UCB/ERL M85/31}},
institution = {Electronics Research Laboratory, College of
Engineering, University of California, Berkeley},

year = {1985} }

hexrd.orientations.matToThetaN(r)[source]

2nd order tensor => angle/axis

to see that angle is right take R in a basis so that R11=1; get tr(R) = 1 + 2 cos(theta), solve for theta and use argument about invariance of tr(R)

references: 1) box 4 in Simo and VuQuoc, 1985, ERL Berkeley memorandum no. UCB/ERL M85/31 2) Marin and Dawson 98 part 1, equation for update d_rstar (exponential mapping)

n is in vector notation of a skew tensor according to w_i = 1/2 epsilon_jik W_jk

hexrd.orientations.quatToInv(q)[source]
hexrd.orientations.quatToMat(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; divide-by-zero is checked using the global ‘tinyRotAng’

hexrd.orientations.quatToProdMat(quat, mult='right')[source]

Form 4 x 4 arrays to perform the quaternion product

USAGE
qmats = quatToProdMat(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:

    / quatToProdMat(h, ‘right’) * q

    q * h –> <

    quatToProdMat(q, ‘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.orientations.sampleToLatticeT2(A_sm, C)[source]
T

[A_sm]=[C][A_lat][C]

hexrd.orientations.latticeToSampleT2(A_lat, C)[source]
T

[A_sm]=[C][A_lat][C]

hexrd.orientations.latticeToSampleV(V_lat, C)[source]
hexrd.orientations.rotMatrixFromCrystalVectors(cvs1=None, cvs2=None, cvs3=None)[source]

Make a rotation matrix in the RotationParameterization convention from components of crystal vectors that are along given sample directions

hexrd.orientations.transposeQuats(qList)[source]
hexrd.orientations.stripQuatList(qList)[source]
hexrd.orientations.writeQuats(qList, f)[source]
hexrd.orientations.makeQuatsBall(qRef, thetaScale, n)[source]

make n quaternions in a ball around qRef, with ball size scaled by thetaScale

hexrd.orientations.makeQuatsComponents(nGrain, scale=None)[source]
hexrd.orientations.millerBravais2Normal(invec, *args)[source]
Generate the normal(s) for a plane(s) given in

the Miller-Bravais convention for the hexagonal basis {a1, a2, a3, c}. The basis for the output {o1, o2, o3} is chosen such that:

o1 || a1 o3 || c o2 = o3 ^ o1

returns a (3, n) array of horizontally concatenated unit vectors