/help/doc/UsersGuide/CrystalGeometry/Rotations.m

https://code.google.com/p/mtex/ · Objective C · 201 lines · 151 code · 50 blank · 0 comment · 2 complexity · 04a4137f71a97bf8ba32ca8865a7ddcb MD5 · raw file

  1. %% Rotations
  2. % Explains how to define rotations and how to switch between different Euler
  3. % angle conventions.
  4. %
  5. %% Open in Editor
  6. %
  7. %% Contents
  8. %
  9. %% Description
  10. %
  11. % Rotations are represented in MTEX by the class *rotation* which is
  12. % inherited from the class <quaternion_index.html quaternion> and allow to
  13. % work with rotations as with matrixes in MTEX.
  14. %
  15. %% Euler Angle Conventions
  16. %
  17. % There are several ways to specify a rotation in MTEX. A
  18. % well known possibility are the so called *Euler angles*. In texture
  19. % analysis the following conventions are commonly used
  20. %
  21. % * Bunge (phi1,Phi,phi2) - ZXZ
  22. % * Matthies (alpha,beta,gamma) - ZYZ
  23. % * Roe (Psi,Theta,Phi)
  24. % * Kocks (Psi,Theta,phi)
  25. % * Canova (omega,Theta,phi)
  26. %
  27. % *Defining a Rotation by Bunge Euler Angles*
  28. %
  29. % The default Euler angle convention in MTEX are the Bunge Euler angles.
  30. % Here a rotation is determined by three consecutive rotations,
  31. % the first about the z-axis, the second about the y-axis, and the third
  32. % again about the z-axis. Hence, one needs three angles two define an
  33. % rotation by Euler angles. The following command defines a rotation by its
  34. % three Bunge Euler angles
  35. o = rotation('Euler',30*degree,50*degree,10*degree)
  36. %%
  37. % *Defining a Rotation by Other Euler Angle Conventions*
  38. %
  39. % In order to define a rotation by a Euler angle convention different to
  40. % the default Euler angle convention you to specify the convention as an
  41. % additional parameter, e.g.
  42. o = rotation('Euler',30*degree,50*degree,10*degree,'Roe')
  43. %%
  44. % *Changing the Default Euler Angle Convention*
  45. %
  46. % The default Euler angle convention can be changed by the command
  47. % <set_mtex_option.html set_mtex_option>, for a permanent change the
  48. % <matlab:edit('mtex_settings.m') mtex_settings> should be edited. Compare
  49. set_mtex_option('EulerAngleConvention','Roe')
  50. o
  51. %%
  52. set_mtex_option('EulerAngleConvention','Bunge')
  53. o
  54. %% Other Ways of Defining a Rotation
  55. %
  56. % *The axis angle parametrisation*
  57. %
  58. % A very simple possibility to specify a rotation is to specify the
  59. % rotation axis and the rotation angle.
  60. o = rotation('axis',xvector,'angle',30*degree)
  61. %%
  62. % *Four vectors defining a rotation*
  63. %
  64. % Given four vectors u1, v1, u2, v2 there is a unique rotation q such that
  65. % q u1 = v1 and q u2 = v2.
  66. o = rotation('map',xvector,yvector,zvector,zvector)
  67. %%
  68. % If only two vectors are specified, then the rotation with the smaller angle is
  69. % returned and gives the rotation from first vector onto the second one.
  70. o = rotation('map',xvector,yvector)
  71. %%
  72. % *A fibre of rotations*
  73. %
  74. % The set of all rotations that rotate a certain vector u onto a certain
  75. % vector v define a fibre in the rotation space. A discretisation of such
  76. % a fibre is defined by
  77. u = xvector;
  78. v = yvector;
  79. o = rotation('fibre',u,v)
  80. %%
  81. % *Defining an rotation by a 3 times 3 matrix*
  82. o = rotation('matrix',eye(3))
  83. %%
  84. % *Defining an rotation by a quaternion*
  85. %
  86. % A last possibility is to define a rotation by a quaternion, i.e., by its
  87. % components a,b,c,d.
  88. o = rotation('quaternion',1,0,0,0)
  89. %%
  90. % Actually, MTEX represents internally every rotation as a quaternion.
  91. % Hence, one can write
  92. q = quaternion(1,0,0,0)
  93. o = rotation(q)
  94. %% Calculating with Rotations
  95. %
  96. % *Rotating Vectors*
  97. %
  98. % Let
  99. o = rotation('Euler',90*degree,90*degree,0*degree)
  100. %%
  101. % a certain rotation. Then the rotation of the xvector is computed via
  102. v = o * xvector
  103. %%
  104. % The inverse rotation is computed via the <rotation.mldivide.html backslash operator>
  105. o \ v
  106. %%
  107. % *Concatenating Rotations*
  108. %
  109. % Let
  110. rot1 = rotation('Euler',90*degree,0,0);
  111. rot2 = rotation('Euler',0,60*degree,0);
  112. %%
  113. % be two rotations. Then the rotation defined by applying first rotation
  114. % one and then rotation two is computed by
  115. rot = rot2 * rot1
  116. %%
  117. % *Computing the rotation angle and the rotational axis*
  118. %
  119. % Then rotational angle and the axis
  120. % of rotation can be computed via then commands
  121. % <quaternion.angle.html angle(rot)> and
  122. % <quaternion.axis.html axis(rot)>
  123. angle(rot)/degree
  124. axis(rot)
  125. %%
  126. % If two rotations are specifies the command
  127. % <quaternion.angle.html angle(rot1,rot2)> computes the rotational angle
  128. % between both rotations
  129. angle(rot1,rot2)/degree
  130. %%
  131. % *The inverse Rotation*
  132. %
  133. % The inverse rotation you get from the command
  134. % <quaternion.inverse.html inverse(rot)>
  135. inverse(rot)
  136. %% Conversion into Euler Angles and Rodrigues Parametrisation
  137. %
  138. % There are methods to transform quaternion in almost any other
  139. % parameterization of rotations as they are:
  140. %
  141. % * <quaternion.Euler.html, Euler(rot)> in Euler angle
  142. % * <quaternion.Rodrigues.html, Rodrigues(rot)> in Rodrigues parameter
  143. %
  144. [alpha,beta,gamma] = Euler(rot,'Matthies')
  145. %% Plotting Rotations
  146. %
  147. % The <quaternion.plot.html plot> function allows you to visualize a
  148. % rotation by plotting how the standard basis x,y,z transforms under the
  149. % rotation.
  150. cla reset;set(gcf,'position',[43 362 400 300])
  151. plot(rot)