Suppose you have a g tensor with three principal values g1, g2, g3 along three principal axis g1, g2 and g3. The axes of the reference frame are labelled x, y and z.
Now suppose that the g3-axis is located in the first octant of the xyz system, with θ=30° and φ=70°. This means that the angle between the g3 and the z axis is θ=30°, and the angle between the x axis and the projection of g3 onto the xy plane is φ=70°.
The direction of g3 in the xyz frame can be easily computed using ang2vec:
phi = 70*pi/180; theta = 30*pi/180; g3 = ang2vec(phi,theta);
g3 =
0.1710
0.4698
0.8660
All the three numbers are positive. They consitute the cosines of the angles between g3 and x, y, and z respectively. They are called direction cosines and denoted l3x, l3y, and l3z, respectively. The subscript 3 stands for the g3 axis.
We can now take this vector and transform it from the xyz representation to the 123 representations using
R = erot([phi theta 0]) R*g3
R =
0.2962 0.8138 -0.5000
-0.9397 0.3420 0
0.1710 0.4698 0.8660
ans =
-0.0000
0
1.0000
% Rotation matrices to be used with erot: % l_x1 l_x2 l_x3 % l_y1 l_y2 l_y3 % l_z1 l_z2 l_z3 % xyz is the reference frame (e.g. crystal frame), and % 123 is the tensor frame (e.g. g or A frame). % Columns are principal tensor axes in reference frame % Rows are reference axes in tensor frame. % % The transformation of a diagonal tensor in its eigenframe 123 % to the reference frame xyz is then % g = R*g_diag*R'; % where is the rotation matrix from above.