swiftsimio.visualisation.rotation module

Rotation matrix calculation routines.

swiftsimio.visualisation.rotation.rotation_matrix_from_vector(vector: float64, axis: str = 'z') array[source]

Calculate a rotation matrix from a vector. The comparison vector is assumed to be along an axis, x, y, or z (by default this is z). The resulting rotation matrix gives a rotation matrix to align the co-ordinate axes to make the projection be top-down along this axis.

Parameters:
  • vector (np.array[float64]) – 3D vector describing the top-down direction that you wish to rotate to. For example, this could be the angular momentum vector for a galaxy if you wish to produce a top-down projection.

  • axis (str, optional) – String describing the axis to project along. This should be one of x, y, or z. Defaults to z.

Returns:

rotation_matrix – Rotation matrix (3x3).

Return type:

np.array[float64]