Rotation

final class narupatools.physics.transformation.Rotation(quat: quaternion.quaternion)

Represents a rotation in 3-dimensional space.

Internally, rotations are stored as quaternions, due to their advantages over other forms such as rotation matrices, rotation vectors and euler angles.

Inheritance

Inheritance diagram of Rotation

Methods

__init__

Initialize self.

around_x_axis

Create a counterclockwise rotation around the x axis.

around_y_axis

Create a counterclockwise rotation around the y axis.

around_z_axis

Create a counterclockwise rotation around the z axis.

from_rotation_vector

Create a rotation from a rotation vector.

rotate_around_center_of_mass

Rotate a set of particles about their center of mass.

rotate_around_point

Rotate a set of points about an arbitrary point \(c\).

__init__(quat: quaternion.quaternion)

Initialize self. See help(type(self)) for accurate signature.

classmethod around_x_axis(angle: float)narupatools.physics.transformation.Rotation

Create a counterclockwise rotation around the x axis.

classmethod around_y_axis(angle: float)narupatools.physics.transformation.Rotation

Create a counterclockwise rotation around the y axis.

classmethod around_z_axis(angle: float)narupatools.physics.transformation.Rotation

Create a counterclockwise rotation around the z axis.

classmethod from_rotation_vector(rot: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[float]])narupatools.physics.transformation.Rotation

Create a rotation from a rotation vector.

rotate_around_center_of_mass(*, masses: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[float]], positions: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[numpy.ndarray[Any, numpy.dtype[numpy.float64]]], Sequence[Sequence[float]]])numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Rotate a set of particles about their center of mass.

Parameters
  • masses – List of masses \(m_i\) of each particle.

  • positions – List of positions \(r_i\) of each particle.

Returns

Set of positions that have been rotated around their center of mass.

rotate_around_point(*, positions: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[numpy.ndarray[Any, numpy.dtype[numpy.float64]]], Sequence[Sequence[float]]], origin: Union[numpy.ndarray[Any, numpy.dtype[numpy.float64]], Sequence[float]])numpy.ndarray[Any, numpy.dtype[numpy.float64]]

Rotate a set of points about an arbitrary point \(c\).

Parameters
  • origin – Point \(c\) about which to rotate the positions.

  • positions – List of positions \(r_i\).

Returns

Set of positions that have been rotated around the origin \(c\).

Attributes

identity

Identity transformation.

inverse

Inverse of this rotation.

rotation_matrix

Rotation matrix representing this rotation.

rotation_vector

Rotation vector representing this rotation.

versor

Unit quaternion (versor) representing this rotation.

identity: ClassVar[narupatools.physics.transformation.Rotation] = <narupatools.physics.transformation.Rotation object>

Identity transformation.

inverse

Inverse of this rotation.

rotation_matrix

Rotation matrix representing this rotation.

rotation_vector

Rotation vector representing this rotation.

This gives a vector who’s direction is the axis of rotation and magnitude is the rotation in radians. It is guaranteed to be the minimum rotation, so the angle will be in the range \([0, \pi)\)

versor

Unit quaternion (versor) representing this rotation.