Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register
Language:
Robots
 Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 250 Accepted: 25

Description

Little Y falls in love with robots recently. It's really a complex job to run a robot. So we will start with a relatively simple work.

A basic problem is to handle the robot hand. The robot hand consists of N + 1 joints which are labeled from 0 to N. There's a hard rod between the kth joint and the k+1th joint. To make the problem simple, we will consider the joints and rods as N + 1 points and N segments (their thickness would be ignored in our problem) in xyz 3D (three-dimensional) coordinates. The 0th joint is always at (0, 0, 0).

As the first step to handle a robot hand, Little Y needs to process some ROs (rotation operation).

There are 3 parameters in RO: an integer idx in [0, N-1], a real number Alpha in [0, 2π] and a 3D non-zero vector P. With such RO, the hand from joint idx to joint N will be rotated. This part will be rotated around an axis for alpha radian. The axis is paralleled to P and passes joint idx. In our rotation, you may assume that movement will not be blocked. Now we’ll explain the direction of rotations. You may easy find out your front (F), back (B), left (L), right (R), up (U) and down (D) direction. Then you may assume x-axis goes from F to B, y-axis goes from L to R and z-axis goes from D to U.

For example, define 3D vectors A(1, 0, 0), B(0, 1, 0) and C(0, 0, 1) and a angle Alpha = π2. Rotate A with Alpha and axis(C) will results in B. Rotate C with Alpha and axis(B) will results in A. Rotate B with Alpha and axis(A) will results in C.

Consider joint idx = (1, 1, 1), rotate (2, 1, 1) with angle = π2 and axis (0, 0, 1) will results in (1, 2, 1).

However, there are so many joints and ROs for Little Y that he cannot handle them! So he asks you for help. Try to help him!

Input

Input file consists of several test cases, for each test case:
The first line contains 2 positive integer N and M (N, M ≤ 50000), which means there are N + 1 joints and M ROs in the test case. In the next N + 1 lines, each line will contains a real number (Xi, Yi, Zi). The next M lines each line starts with an integer CMD which is 1 or 2.
If CMD = 2, then it follows an integer t in [0, N]. It means a query to the position of joint t.
If CMD = 1, then it follows 5 number idx, alpha, (Xp, Yp, Zp), standing for a rotation operation .
The input file ends with one line consisting of two 0 separated by a space.
You may assume all real numbers in input data are smaller than 104 in absolute value.

Output

For each test case:
For each operation with CMD = 2, output one line containing 3 real number (Xt, Yt, Zt), describing the position of joint t. Keep 4 digits after the decimal point.
Output an empty line after each test case.

Sample Input

```1 2
0 0 0
1 0 0
1 0 1.5707963267948966192313216916398 0 0 1
2 1
2 3
0 0 0
1 0 0
2 0 0
1 0 1.5707963267948966192313216916398 0 0 1
1 1 1.5707963267948966192313216916398 1 0 0
2 2
0 0
```

Sample Output

```0.0000 1.0000 0.0000

0.0000 1.0000 1.0000

```

Source

[Submit]   [Go Back]   [Status]   [Discuss] Home Page Go Back To top
{"ft_lang_label":"__label__en","ft_lang_prob":0.8620118,"math_prob":0.96155226,"size":3325,"snap":"2020-45-2020-50","text_gpt3_token_len":1022,"char_repetition_ratio":0.09936766,"word_repetition_ratio":0.02177294,"special_character_ratio":0.32902256,"punctuation_ratio":0.13842173,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9806479,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],"im_url_duplicate_count":[null,null,null,null,null,null,null,2,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-12-04T02:15:13Z\",\"WARC-Record-ID\":\"<urn:uuid:91dd8727-59e6-420a-9c35-0efc4dbc4b85>\",\"Content-Length\":\"8694\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:14a56549-21d1-4269-9b85-c61e61ddc0ba>\",\"WARC-Concurrent-To\":\"<urn:uuid:64c627c5-473e-4715-85c7-2b82973947bc>\",\"WARC-IP-Address\":\"168.235.95.213\",\"WARC-Target-URI\":\"http://poj.org/problem?id=3247\",\"WARC-Payload-Digest\":\"sha1:V7F5EGZVNXQHK356XMAFRL7XHF7INXG3\",\"WARC-Block-Digest\":\"sha1:RVXI4BVUVGBBTQJ4KVQE5KTWP2EOC5C4\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-50/CC-MAIN-2020-50_segments_1606141733120.84_warc_CC-MAIN-20201204010410-20201204040410-00309.warc.gz\"}"}