Rotation
- class geoteqpy.Rotation(angle: float, axis: ndarray)
Class to perform 3D rotations.
- Parameters:
angle (float) – Angle of rotation
axis (numpy.ndarray) – Axis of rotation, expected shape
(3,). The vector is expected to be normalized.
- Attributes:
- angle: float
Angle of rotation
- axis: numpy.ndarray
Axis of rotation
- Methods:
- rotate_referential(self, coor, O, L, ccw=True)
Rotate the referential of the coordinates \(\mathbf{x}\) given the rotation matrix \(\boldsymbol R\). The referential is first translated to be centred on \(\mathbf{0}\), then rotated and finally translated back to its original position.
\[\begin{split}\mathbf x_T &= \mathbf x - \frac{1}{2}(\mathbf L + \mathbf O) \\ \mathbf x_{TR} &= \boldsymbol R \mathbf x_T \\ \mathbf x_R &= \mathbf x_{TR} + \frac{1}{2}(\mathbf L + \mathbf O)\end{split}\]- Parameters:
coor (np.ndarray) – coordinates to be rotated of the shape
(npoints,dim)O (np.ndarray) – origin of the referential of the shape
(dim,)L (np.ndarray) – maximum coordinates of the referential of the shape
(dim,)ccw (bool) – rotate counter-clockwise (default is True)
- Returns:
Rotated coordinates of the shape
(npoints,dim)
- rotate_tensor(R: ndarray, tensor: ndarray, ccw: bool = True) ndarray
Rotate a tensor such that
\[\boldsymbol{\tau}_R = \boldsymbol{R} \boldsymbol{\tau} \boldsymbol{R}^T\]- Parameters:
R (np.ndarray) – rotation matrix of the shape
(dim,dim)tensor (np.ndarray) – tensor(s) to be rotated of the shape
(npoints,dim,dim)ccw (bool) – rotate counter-clockwise (default is True)
- Returns:
Rotated tensor of the shape
(npoints,dim,dim)
- rotate_vector(R: ndarray, u: ndarray, ccw: bool = True) ndarray
Rotate vector(s) \(\mathbf u\) given the rotation matrix \(\boldsymbol R\).
Warning
This is not a rotation of the vector field, but a rotation of the vectors themselves.
- Parameters:
R (np.ndarray) – rotation matrix of the shape
(dim,dim)u (np.ndarray) – vector(s) to be rotated of the shape
(npoints,dim)ccw (bool) – rotate counter-clockwise (default is True)
- Returns:
Rotated vector of the shape
(npoints,dim)
- rotation_matrix() ndarray
Construct the 3D rotation matrix for an angle \(\theta\) and a rotation axis \(\mathbf r\).
- Returns:
The rotation matrix. Shape
(3,3)- Ret type:
numpy.ndarray