Rotation#

class cbclib.Rotation(matrix=array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]))[source]#

A rotation matrix implementation. Provides auxiliary methods to work with Euler and tilt angles.

Parameters

matrix (ndarray) – Rotation matrix.

contents()#

Return a list of the attributes stored in the container that are initialised.

Return type

List[str]

Returns

List of the attributes stored in the container.

get(attr, value=None)#

Retrieve a dataset, return value if the attribute is not found.

Parameters
  • attr (str) – Data attribute.

  • value (Optional[Any]) – Data which is returned if the attribute is not found.

Return type

Any

Returns

Attribute’s data stored in the container, value if attr is not found.

classmethod import_euler(angles)[source]#

Calculate a rotation matrix from Euler angles with Bunge convention [EUL].

Parameters

angles (Union[ndarray, List[float], Tuple[float, float, float]]) – Euler angles \(\phi_1, \Phi, \phi_2\).

Return type

Rotation

Returns

A new rotation matrix Rotation.

classmethod import_tilt(angles)[source]#

Calculate a rotation matrix for a set of three angles set of three angles \(\theta, \alpha, \beta\), a rotation angle \(\theta\), an angle between the axis of rotation and OZ axis \(\alpha\), and a polar angle of the axis of rotation \(\beta\).

Parameters

angles (Union[ndarray, List[float], Tuple[float, float, float]]) – A set of angles \(\theta, \alpha, \beta\).

Return type

Rotation

Returns

A new rotation matrix Rotation.

items()#

Return (key, value) pairs of the datasets stored in the container.

Return type

ItemsView

Returns

(key, value) pairs of the datasets stored in the container.

keys()#

Return a list of the attributes available in the container.

Return type

List[str]

Returns

List of the attributes available in the container.

reciprocate()[source]#

Invert the rotation matrix.

Return type

Rotation

Returns

An inverse rotation matrix.

replace(**kwargs)#

Return a new container object with a set of attributes replaced.

Parameters

kwargs (Any) – A set of attributes and the values to to replace.

Return type

~D

Returns

A new container object with updated attributes.

to_euler()[source]#

Calculate Euler angles with Bunge convention [EUL].

Return type

ndarray

Returns

A set of Euler angles with Bunge convention \(\phi_1, \Phi, \phi_2\).

to_tilt()[source]#

Calculate an axis of rotation and a rotation angle for a rotation matrix.

Return type

ndarray

Returns

A set of three angles \(\theta, \alpha, \beta\), a rotation angle \(\theta\), an angle between the axis of rotation and OZ axis \(\alpha\), and a polar angle of the axis of rotation \(\beta\).

values()#

Return the attributes’ data stored in the container.

Return type

ValuesView

Returns

List of data stored in the container.