POJ 1835 Astronaut: Analog & three-dimensional vector rotation

Source: Internet
Author: User
Tags relative first row

Description

Problem Description:
The astronauts lost their way in space, and now in his starting position, a virtual XYZ coordinate system, called an absolute coordinate system, in which the astronaut's frontal orientation is in the positive direction of the x-axis and the head is in the direction of the z-axis, the initial state of the astronaut is shown in the following illustration:

The six directions are respectively labeled, the x,y,z positive direction respectively is 0,1,2, the negative direction is 3,4,5 respectively, and they are called absolute directions. The astronaut walks in the universe only in the direction parallel to the XYZ axis of the absolute coordinate system, but he does not know his current absolute coordinates and the absolute direction he is facing.

Task Description:
Please determine the final absolute coordinates and orientation of the astronauts according to the astronauts ' description of their movements in the opposite direction. The description and significance of moving in a relative direction are as follows:
Forward x walk forward x m.
Back x turns first, then walks x meters.
Left X turns first and then x M.
Right x turns first and then x M.
Up X first face up, then walk x m.
Down X first face down, then walk x meters.
It looks up and down as shown in the following illustration:

Input

The first line is a positive integer m representing the number of groups to test the data. The first row of each set of test data is a positive integer n (1<=n<=10000) indicating the number of times astronauts walk, the following n rows per line Enter a relative walk, format as described above, where (1 <= x <= 10000 is a positive integer).

Output

For each set of input data output one row, x y z p, the middle is separated by a space, x y z is the absolute coordinates of the astronaut's position, p is the astronaut-oriented absolute direction number (0<=p <=5).

Sample Input

1 6 left Right one up
forward
15

Sample Output

23-10 12 3

Idea: Use a three-dimensional vector to record the direction of the human body--facing direction, the body vertical direction upward direction, the human left arm horizontally.

6 kinds of transformations are operations on this vector. (see Code for details)

Note: The title is the left-hand coordinate system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.