#P5388. Geometer's Sketchpad
Geometer's Sketchpad
Problem Description
The Geometer's Sketchpad is a popular commercial interactive geometry software program for exploring Euclidean geometry, algebra, calculus, and other areas of mathematics.
The Geometer's Sketchpad can solve most problems of plane geometry and plane analytic geometry, but it's powerless to solve solid geometry problems. Therefore, the famous mathematician BG, decided to develop a new software, named The Geometer's Sketchpad 3D.
Because of the huge amount of work to do, BG decided to start from basic three-dimensional transformations. Similar to two-dimensional transformations, three-dimensional transformations include three basic types:
1. Translation.

2. Scaling.

3. Rotation.

Now there are $n$ points $P_1,P_2,P_3,\ldots,P_n$ in the three-dimensional space, and BG wanted to implement the following several transformation operations:
1. For given integers $l,r,x,y,z$, translate points $P_l,P_{l+1},P_{l+2},\ldots,P_r$ by the vector $(x,y,z)$ at the same time;
2. For given integers $l,r,x,y,z$ and the real number $k$, scale points $P_l,P_{l+1},P_{l+2},\ldots,P_r$ by the scale factor $k$ and the center point $(x,y,z)$ at the same time;
3. For given integers $l,r,x,y,z,x',y',z'$ and the real number $\theta$, rotate points $P_l,P_{l+1},P_{l+2},\ldots,P_r$ counterclockwise around the axis determined by the point $(x,y,z)$ and the direction vector $(x',y',z')$ through an angle $\theta$ (in radian) at the same time.
In addition, there are some measurement operations:
1. For given integer $i$, calculate the current coordinates of the point $P_i$;
2. For given integers $l,r$, calculate the current length of the polygonal chain $P_{l}P_{l+1}P_{l+2}\cdots P_{r}$. In other words, just calculate $|P_lP_{l+1}|+|P_{l+1}P_{l+2}|+\cdots+|P_{r-1}P_r|$, where $|PQ|$ means the Euclidean distance between points $P$ and $Q$.
Input
There are multiple test cases.
For each test case:
The first line contains two positive integers $n,m~(1\le n,m \le 222222)$, representing the number of points and the number of operations.
Next $n$ lines, each line contains three integers $x,y,z$, representing a point $(x,y,z)$ in the three-dimensional space.
Next $m$ lines, each line describes an operation (without quotes):
1. "$\mathtt{Translation}~l~r~x~y~z$", translate points;
2. "$\mathtt{Scaling}~l~r~x~y~z~k$", scale points;
3. "$\mathtt{Rotation}~l~r~x~y~z~x'~y'~z'~\theta$", rotate points;
4. "$\mathtt{Coordinates}~i$", calculate the current coordinates of the point;
5. "$\mathtt{Length}~l~r$", calculate the current length of the polygonal chain.
There is one blank line between successive tests. Values of $n=m=0$ indicate end of input.
For the all of the above variables, $1 \le l,r,i \le n$, $-1000 \le x,y,z,x',y',z' \le 1000$, $0 < k \le 2$, $-10 \le \theta \le 10$. $k$ and $\theta$ are real numbers, given with at most $6$ digits after the decimal point, and all other numbers are integers. You can sure that the absolute value of the answer does not exceed $10^{10}$ at any time.
It is guaranteed $\sum n+\sum m \le 10^6$.
Output
For each test case:
First output one line containing "$\texttt{Case #}i\texttt{:}$"(without quotes), where $i$ is the test case number (starting from $1$).
Then, for each "$\mathtt{Coordinates}$" operator, output one line containing three space-separated real numbers, representing the current coordinates of the point; for each "$\mathtt{Length}$" operator, output one line containing a real number, representing the current length of the polygonal chain.
Your output will be considered correct if the absolute or relative error of every number does not exceed $10^{-4}$.
5 10
0 0 0
2 0 0
2 1 0
0 1 0
0 0 0
Translation 1 5 1 1 0
Scaling 2 4 1 1 0 2
Coordinates 2
Coordinates 3
Length 2 3
Rotation 1 5 0 0 0 0 0 1 1.570796
Translation 1 2 0 0 100
Coordinates 2
Coordinates 3
Length 2 3
0 0
</p>
Case #1:
5.0000 1.0000 0.0000
5.0000 3.0000 0.0000
2.0000
-1.0000 5.0000 100.0000
-3.0000 5.0000 0.0000
100.0200
Author
SXYZ