PIXELBANKv8.2.1
Menu

2D Rotation Matrix

Implement a 2D rotation matrix for a given angle and apply it to rotate a point. This task involves understanding linear transformations and matrix multiplication to achieve the desired rotation.

The concept of rotation in 2D space is crucial in computer vision and graphics, where it is used to change the orientation of objects. A 2D rotation by angle θ\theta (counterclockwise) can be represented using trigonometric functions. To rotate a point, we can follow these steps:

  1. Convert the given angle to a suitable format for calculation.
  2. Create the rotation matrix using the angle.
  3. Apply the rotation matrix to the point.
(xy)=(cosθsinθsinθcosθ)(xy)\begin{pmatrix} x' \\ y' \end{pmatrix} = \begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix}

This technique is widely used in image processing.

Example:

Input:
rotate_point([1, 0], 90)
Output:
[0.0, 1.0]
Reasoning:

Rotating (1, 0) by 90° counterclockwise gives (0, 1)

Constraints:

  • Angle is given in degrees
  • Point coordinates are floating-point numbers
  • Return the rotated point [x', y'] rounded to 4 decimal places
Editor

Test Results

0/0
Run code to see test results.