parse_rotation
- sisl.utils.parse_rotation(rotation, rad, abc=None)
Parses a sequence of rotation arguments.
- Parameters:
rotation (Tuple[float, str | Sequence[float]] | Sequence[float] | Quaternion | Sequence[Tuple[float, str | Sequence[float]] | Sequence[float] | Quaternion]) – the rotations that is to be parsed and collected.
rad (bool) – whether angles specified in the rotation argument are in radians. Currently, one cannot combine radians and degree angles.
abc (ndarray | None) – the vectors that any string ‘abc` in the rotation argument will be translated to.
- Return type:
Examples
A rotation of 45 degrees around the \(x\) axis. >>> q = parse_rotation([45, “x”], rad=False)
A rotation of 45 degrees around the \(y\) axis, but specified through the 2nd index of the abc argument >>> q = parse_rotation([45, “b”], rad=False, abc=[[1, 0, 0], [0, 1, 0], [0, 0, 1]])
A rotation of 45 degrees around the \(xy\) plane: >>> q = parse_rotation([45, “xy”], rad=False)
A rotation of 45 degrees around the vector along \(x+y\): >>> q = parse_rotation([45, “x+y”], rad=False)
Explicitly specify the angle and the vector of rotation (around \(xy\) vector) >>> q = parse_rotation([np.pi/4, [0.4, 0.4, 0]])
Explicitly specify the angle of rotation around all three Cartesian coordinates >>> q = parse_rotation([np.pi/4, np.pi/2, np.pi/4])
Specify a list of rotations: >>> q = parse_rotation([ … [np.pi/4, np.pi/2, np.pi/4], … [np.pi/3, “x”], … [np.pi/3, (0.1, 0.2, 0.3)], rad=True)
See also
Quaternionreturned class
Quaternion.rotation_matrixto retrieve an explicit rotation matrix.