aerosandbox.numpy.rotations =========================== .. py:module:: aerosandbox.numpy.rotations Functions --------- .. autoapisummary:: aerosandbox.numpy.rotations.rotation_matrix_2D aerosandbox.numpy.rotations.rotation_matrix_3D aerosandbox.numpy.rotations.rotation_matrix_from_euler_angles aerosandbox.numpy.rotations.is_valid_rotation_matrix Module Contents --------------- .. py:function:: rotation_matrix_2D(angle, as_array = True) Gives the 2D rotation matrix associated with a counterclockwise rotation about an angle. :param angle: Angle by which to rotate. Given in radians. :param as_array: Determines whether to return an array-like or just a simple list of lists. Returns: The 2D rotation matrix .. py:function:: rotation_matrix_3D(angle, axis, as_array = True, axis_already_normalized = False) Yields the rotation matrix that corresponds to a rotation by a specified amount about a given axis. An implementation of https://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle :param angle: The angle to rotate by. [radians] :param Direction of rotation corresponds to the right-hand rule.: :param Can be vectorized.: :param axis: The axis to rotate about. [ndarray] :param Can be vectorized; be sure axis[0] yields all the x-components: :param etc.: :param as_array: boolean, returns a 3x3 array-like if True, and a list-of-lists otherwise. If you are intending to use this function vectorized, it is recommended you flag this False. (Or test before proceeding.) :param axis_already_normalized: boolean, skips axis normalization for speed if you flag this true. :returns: The rotation matrix, with type according to the parameter `as_array`. .. py:function:: rotation_matrix_from_euler_angles(roll_angle = 0, pitch_angle = 0, yaw_angle = 0, as_array = True) Yields the rotation matrix that corresponds to a given Euler angle rotation. Note: This uses the standard (yaw, pitch, roll) Euler angle rotation, where: * First, a rotation about x is applied (roll) * Second, a rotation about y is applied (pitch) * Third, a rotation about z is applied (yaw) In other words: R = R_z(yaw) @ R_y(pitch) @ R_x(roll). Note: To use this, pre-multiply your vector to go from body axes to earth axes. Example: >>> vector_earth = rotation_matrix_from_euler_angles(np.pi / 4, np.pi / 4, np.pi / 4) @ vector_body See notes: http://planning.cs.uiuc.edu/node102.html :param roll_angle: The roll angle, which is a rotation about the x-axis. [radians] :param pitch_angle: The pitch angle, which is a rotation about the y-axis. [radians] :param yaw_angle: The yaw angle, which is a rotation about the z-axis. [radians] :param as_array: If True, returns a 3x3 array-like. If False, returns a list-of-lists. Returns: .. py:function:: is_valid_rotation_matrix(a, tol=1e-09) Returns a boolean of whether the given matrix satisfies the properties of a rotation matrix. Specifically, tests for: * Volume-preserving * Handedness of output reference frame * Orthogonality of output reference frame :param a: The array-like to be tested :param tol: A tolerance to use for truthiness; accounts for floating-point error. Returns: A boolean of whether the array-like is a valid rotation matrix.