create_rotation_matrix

pyhelpers.ops.create_rotation_matrix(theta)[source]

Create a 2D rotation matrix for counterclockwise rotation.

Parameters:

theta (float | int) – Rotation angle in radians.

Returns:

Rotation matrix of shape (2, 2).

Return type:

numpy.ndarray

Note

  • The rotation matrix is defined as:

    [[cos(theta), -sin(theta)],
     [sin(theta), cos(theta)]]
    
  • For counterclockwise rotation, the matrix rotates points in the positive direction (i.e. the positive x-axis rotates towards the positive y-axis).

Examples:

>>> from pyhelpers.ops import create_rotation_matrix
>>> rot_mat = create_rotation_matrix(theta=30)
>>> rot_mat
array([[-0.98803162,  0.15425145],
       [-0.15425145, -0.98803162]])