Trigonometric functions describe some behavior of circles (or of triangles,
depending on which model you use for interpretation). At their core, trigonometric
functions answer the following question: Given a circle centered at the origin
with radius R, what are the (x, y) coordinates of any chosen point on the circle?
The first thing we must do is draw a line from the chosen point to the origin, and
then measure the angle θ of that line with the positive x-axis, moving counter-clockwise
from the positive x-axis. It's important that we measure the angle in units of
radians, rather than degrees - while a full rotation around the circle requires
360°, that same full rotation would take likewise require 2π radians. We can
then define the (x, y) coorindates of the chosen point with the following trigonometric
functions:
$$ \large x = R \cdot \cos(\theta) $$ $$ \large y = R \cdot \sin(\theta) $$
A circle with R = 1.
So how do we actually compute these values? To do this by hand, we would compute an approximation using a Taylor Series. The exact reasoning of why Taylor Series work so well in approximating functions at exact points is somewhat beyond the scope of this task, but here is the end result of the method:
$$ \large \cos(\theta) = \sum_{n=0}^{\infty} \frac{(-1)^n}{(2n)!} \cdot \theta^{2n} = 1 - \frac{\theta^2}{2!} + \frac{\theta^4}{4!} - \frac{\theta^6}{6!} + \space ... $$ $$ \large \sin(\theta) = \sum_{n=0}^{\infty} \frac{(-1)^n}{(2n + 1)!} \cdot \theta^{2n+1} = \theta - \frac{\theta^3}{3!} + \frac{\theta^5}{5!} - \frac{\theta^7}{7!} + \space ... $$
Each of the above examples shows the first 4 terms in each series.
The more terms are added, the closer the approximation approaches the exact value.
You will be given several values of R and θ, and you must approximate the (x, y) values of the described point.
Input Data
First line will be Q, the quantity of testcases.
Q lines will then follow, each with three space-separated values in the format R θ T.
Note that θ will be given in units of degrees. Be sure to convert to radians as necessary.
Answer
Should consist of 2 * Q space-separated values, consisting of the approximated x y cooridinates of each corresponding point.
Approximate all sin and cos values using Taylor approximations with T terms.
Error should be less than 1e-6.
Example
input data:
4
1 60 1
1 60 3
1 60 5
2 -70 7
answer:
1 1.047198 0.501796 0.866295 0.5 0.866025 0.68404 -1.879385