Difference between revisions of "Rotmat align.m"

From Spinach Documentation Wiki
Jump to: navigation, search
m (Add missing Version/authors metadata and remove raw author emails)
(Update function See also links and function index membership)
 
(2 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
  rot_mat=rotmat_align(v_from,v_to)
 
  rot_mat=rotmat_align(v_from,v_to)
  
−
==Arguments==
+
==Parameters==
  
 
  v_from  - three-element real vector to rotate
 
  v_from  - three-element real vector to rotate
−
 
+
 
     v_to    - three-element real vector to align to
 
     v_to    - three-element real vector to align to
  
Line 17: Line 17:
 
  rot_mat  - 3x3 rotation matrix that satisfies
 
  rot_mat  - 3x3 rotation matrix that satisfies
 
               rot_mat*(v_from/norm(v_from,2))=v_to/norm(v_to,2)
 
               rot_mat*(v_from/norm(v_from,2))=v_to/norm(v_to,2)
−
 
+
 
  Note: aligning one vector with another leaves one rotational degree of
 
  Note: aligning one vector with another leaves one rotational degree of
 
       freedom around the aligned direction. If the resulting matrix is
 
       freedom around the aligned direction. If the resulting matrix is
Line 29: Line 29:
  
 
==See also==
 
==See also==
−
[[euler2dcm.m]], [[dcm2euler.m]], [[anax2dcm.m]], [[Kernel_utilities#Rotations|Rotations]]
+
[[euler2dcm.m]], [[dcm2euler.m]], [[anax2dcm.m]], [[anax2quat.m]], [[axis_tsymm.m]], [[dcm2wigner.m]], [[euler_sup.m]], [[quat2anax.m]], [[rotor_stack.m]], [[wigner.m]], [[xyz2sph.m]], [[Kernel_utilities]]
  
 
''Version 2.11, authors: [[Alexey Bogdanov]]''
 
''Version 2.11, authors: [[Alexey Bogdanov]]''

Latest revision as of 18:41, 6 June 2026


Rotation matrix aligning one vector with another vector.

Syntax

rot_mat=rotmat_align(v_from,v_to)

Parameters

v_from   - three-element real vector to rotate

   v_to     - three-element real vector to align to

Outputs

rot_mat  - 3x3 rotation matrix that satisfies
              rot_mat*(v_from/norm(v_from,2))=v_to/norm(v_to,2)

Note: aligning one vector with another leaves one rotational degree of
      freedom around the aligned direction. If the resulting matrix is
      converted to ZYZ Euler angles, this freedom appears as a non-uni-
      que third Euler angle (the twist around the aligned axis). This
      implementation fixes that freedom by returning the minimum-
      angle alignment without any additional twist around the aligned
      direction. In the anti-parallel case the axis is non-unique, and
      the first null-space basis vector orthogonal to v_from is used.


See also

euler2dcm.m, dcm2euler.m, anax2dcm.m, anax2quat.m, axis_tsymm.m, dcm2wigner.m, euler_sup.m, quat2anax.m, rotor_stack.m, wigner.m, xyz2sph.m, Kernel_utilities

Version 2.11, authors: Alexey Bogdanov