erot#

torchspin.erot(angles_or_alpha, beta=None, gamma=None, device='cpu')[source]#

Passive rotation matrix from Euler angles (z-y’-z’’ convention).

Matches EasySpin’s erot function exactly. The matrix is real-valued.

Parameters:
  • angles_or_alpha – Either a 3-element sequence/tensor (alpha, beta, gamma) in radians, or just alpha when beta and gamma are given as separate args.

  • beta – Second Euler angle in radians (only used when passing 3 separate args).

  • gamma – Third Euler angle in radians (only used when passing 3 separate args).

  • device (str) – PyTorch device string.

Returns:

torch.Tensor – 3×3 real rotation matrix (float64). If an angle is a tensor that requires grad, the matrix is built from torch operations and carries the gradient with respect to the angles; otherwise it is computed in Python floats (as before) and does not require grad.

Return type:

Tensor

Notes

The explicit decomposition is:

Rg = Rz(gamma)
Rb = Ry(beta)
Ra = Rz(alpha)
R  = Rg @ Rb @ Ra

which matches the formula in erot.m:

R = [ cg*cb*ca-sg*sa,   cg*cb*sa+sg*ca,  -cg*sb;
     -sg*cb*ca-cg*sa,  -sg*cb*sa+cg*ca,   sg*sb;
      sb*ca,            sb*sa,             cb ]