#K71287. Rotating 2D Points
Rotating 2D Points
Rotating 2D Points
You are given a set of 2D points and an angle (in degrees). Your task is to rotate each point counter-clockwise about the origin by the given angle using the rotation matrix. In mathematical form, for a point \((x, y)\) and an angle \(\theta\) (in degrees), the new coordinates \((x', y')\) are computed as follows:
\[ x' = x \cos\theta - y \sin\theta \] \[ y' = x \sin\theta + y \cos\theta \]
Note: The angle must first be converted from degrees to radians using the formula \(\theta_{rad} = \theta \times \frac{\pi}{180}\).
Output each rotated point with six decimal places. The order of the points in the output should be the same as in the input.
inputFormat
The first line contains two numbers: an integer \(n\) and a float \(a\), where \(n\) represents the number of points and \(a\) is the angle in degrees by which the points are to be rotated.
The next \(n\) lines each contain two space-separated real numbers representing the coordinates \(x\) and \(y\) of a point.
For example:
4 90.0 1.0 0.0 0.0 1.0 -1.0 0.0 0.0 -1.0
outputFormat
Output \(n\) lines, each line containing the rotated coordinates of the point corresponding to the input. Each coordinate must be printed with exactly six decimal places and separated by a space.
For example:
0.000000 1.000000 -1.000000 0.000000 0.000000 -1.000000 1.000000 0.000000## sample
4 90.0
1.0 0.0
0.0 1.0
-1.0 0.0
0.0 -1.0
0.000000 1.000000
-1.000000 0.000000
0.000000 -1.000000
1.000000 0.000000
</p>