ImageD11.gv_general | index /sware/exp/fable/standalone/redhate4-a64/lib/python2.5/site-packages/ImageD11/gv_general.py

`Find a generalised way to compute g-vectors backwards and forwards`

Modules
`` |  |
logging | math | numpy |

Classes
`` |  | rotation_axis
class rotation_axis
`` | `Represents an axis - so far includes: axis/angle matrix (direction cosines) potentially can add quaternions and euler etc later?`
| Methods defined here: __init__(self, direction, angle=0.0) `direction is the rotation direction angle is the angle of rotation (degrees)` rotate_vectors(self, vectors, angles=None) `Given a list of vectors, rotate them to new ones Angle is either self.angle, or 1 per vector, in degrees http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/rotation.html p' = a . p a + (p - a . p a) cos q + a * p sin q = p cos q + a . p a (1-cos q) + a * p sin q point p, axis a, angle q http://mathworld.wolfram.com/RotationFormula.html r' = r cos(t) + n(n.r)(1-cos(t)) + rxn sin(t)` rotate_vectors_inverse(self, vectors, angles=None) `Same as rotate vectors, but opposing sense` to_matrix(self) `Returns a 3x3 rotation matrix R = I3cos(t) + ww^T (1-cos(t)) - W sin(t) t = angle W = vector with hat operator = [ 0 -wz wy wz 0 -wx -wy wx 0 ]`

Functions
`` |  | axis_from_matrix(m) `Factory method to create a rotation_axis object from a direction cosine matrix http://en.wikipedia.org/wiki/Rotation_representation_%28mathematics%29` g_to_k(g, wavelength, axis=array([ 0., 0., 1.]), pre=None, post=None) `Get the k and angles given the g in g = pre . rot(axis, angle) . post . k ...where k will satisfy the Laue equations The recipe is: Find the components of g along and perpendicular to the rotation axis co-ords are a0 = axis, a1 = axis x g, a2 = a1 x axis = ( axis x g ) x axis Rotated vector will be a0 + a1 sin(angle) + a2 cos(angle) Laue condition says that [incident beam].[k] = k.sin(theta) = 2 sin^2(theta) / lambda = sin(t)/d = |g|.sin(t) = |g|*|g|*lambda / 2 Apply any post rotations to the incident beam Apply any pre-rotations to the g vector |g| = [a0 + a1 sin(angle) + a2 cos(angle) ] . [incident beam] => solve for angle http://www.ping.be/~ping1339/gonio.htm a sin(u) + b cos(u) = c let: tan(u') = -b/a and: A = a / cos(u') Finally you'll find: A.sin(u-u') = c A.cos(pi/2 - u - u') = c` k_to_g(k, angles, axis=<ImageD11.gv_general.rotation_axis instance at 0x2a9c40bea8>, pre=<ImageD11.gv_general.rotation_axis instance at 0x2a9c40b680>, post=<ImageD11.gv_general.rotation_axis instance at 0x2a9c40b680>) `Computes g = pre . rot(axis, angle) . post . k Typically in ImageD11 pre = [wedge][chi] and post = identity`

Data
`` |  | rotate_identity = <ImageD11.gv_general.rotation_axis instance at 0x2a9c40b680>