def rotation_matrix(self, angle): """Return the rotation matrix to the system state at ``angle``. The matrix is computed according to `Rodrigues' rotation formula <https://en.wikipedia.org/wiki/Rodrigues'_rotation_formula>`_. Parameters ---------- angle : float or `array-like` Angle(s) in radians describing the counter-clockwise rotation of the system around `axis`. Returns ------- rot : `numpy.ndarray` The rotation matrix (or matrices) mapping vectors at the initial state to the ones in the state defined by ``angle``. The rotation is extrinsic, i.e., defined in the "world" coordinate system. If ``angle`` is a single parameter, the returned array has shape ``(3, 3)``, otherwise ``angle.shape + (3, 3)``. """ squeeze_out = (np.shape(angle) == ()) angle = np.array(angle, dtype=float, copy=False, ndmin=1) if (self.check_bounds and not is_inside_bounds(angle, self.motion_params)): raise ValueError('`angle` {} not in the valid range {}' ''.format(angle, self.motion_params)) matrix = axis_rotation_matrix(self.axis, angle) if squeeze_out: matrix = matrix.squeeze() return matrix
def rotation_matrix(self, angle): """Return the matrix for rotating around `axis` by ``angle``. The matrix is computed according to `Rodrigues' rotation formula <https://en.wikipedia.org/wiki/Rodrigues'_rotation_formula>`_. Parameters ---------- angle : float Motion parameter given in radians. It must be contained in this geometry's `motion_params`. Returns ------- rot_mat : `numpy.ndarray`, shape ``(3, 3)`` The rotation matrix mapping the standard basis vectors in the fixed ("lab") coordinate system to the basis vectors of the local coordinate system of the detector reference point, expressed in the fixed system. """ angle = float(angle) if angle not in self.motion_params: raise ValueError('`angle` {} is not in the valid range {}' ''.format(angle, self.motion_params)) return axis_rotation_matrix(self.axis, angle)