No.760 Where am I moved to?
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
Problem Statement
Some time ago, you were on a ship floating on the sea.
It is known that the ship was at point $(x_a,y_a)$, as seen from an XY coordinate system fixed to the world (the world coordinate system), and was facing direction $\theta_a$ (directions are the same as in mathematical polar coordinates).
The ship also has an XY coordinate system fixed to it (the ship coordinate system), whose X axis points in the direction the ship is facing.
The ship coordinate system moves together with the ship.
$2$ stakes that never move are driven into the sea.
It is known that stake $1$ is at $(x_{11},y_{11})$ and stake $2$ is at $(x_{12},y_{12})$ in the world coordinate system.
The ship is equipped with a device that measures the positions of the stakes in the ship coordinate system.
Using this device, you can obtain the coordinates of stake $1$ and stake $2$ as seen from the ship coordinate system.
Since then, some time has passed and the ship has drifted, so you no longer know your position.
You therefore assumed that the ship was still at its previous position and direction, and calculated the "apparent world coordinates of the stakes" from the following information.
・The previous position of the ship
・The coordinates of stake $1$ and stake $2$ obtained from the device on the ship
The "apparent world coordinates of the stakes" of stake $1$ and stake $2$ were $(x_{21},y_{21})$ and $(x_{22},y_{22})$, respectively.
You realized that you can calculate the current position of the ship by comparing the "apparent world coordinates of the stakes" with the actual coordinates of the stakes.
Calculate the current position $(x_b,y_b)$ and direction $\theta_b$ of the ship as seen from the world coordinate system.
Input
xa ya θa x11 y11 x12 y12 x21 y21 x22 y22
$x_a, y_a \theta_a$: your (the ship's) previous world coordinates and direction (decimals)
$x_{11} \cdots y_{12}$: the world coordinates of the $2$ stakes (decimals)
$x_{21} \cdots y_{22}$: the current (apparent) world coordinates of the $2$ stakes (decimals)
Stake $1$ and stake $2$ are distinguishable.
The positions of stake $1$ and stake $2$ are different.
$0^{\circ} \le \theta_a \le 360^{\circ}$
$-10000 \le x_a, y_a, x_{11} \cdots y_{22} \le 10000$
The Euclidean distance between $(x_{11}, y_{11})$ and $(x_{12}, y_{12})$ and the Euclidean distance between $(x_{21}, y_{21})$ and $(x_{22}, y_{22})$ are equal (with a precision of at least 1e-9)
Output
xb yb θb
$x_b, y_b, \theta_b$: your (the ship's) current world coordinates and direction (decimals)
Your answer is judged correct if, supposing you had moved to your "current coordinates and direction", the new apparent coordinates of $(x_{11}, y_{11}), (x_{12}, y_{12})$ are each within a Euclidean distance of less than 1e-5 from the coordinates $(x_{21}, y_{21}), (x_{22}, y_{22})$, respectively. $\theta_b$ does not need to be within the range from 0° to 360°.
Sample
Sample 1
Input
0 0 90 0 1 -1 1 1 0 1 1
Output
0 0 180
For stake $1$ to appear to have moved from (0,1) to (1,0), and stake $2$ from (-1,1) to (1,1), you should set the axes of the ship coordinate system so that up is +x and left is +y. To create such a coordinate system, you should rotate yourself by a further 90°.
0.0 0.0 180.0 is also accepted.
Sample 2
Input
1 2 0 3 3 4 4 2 2 3 3
Output
2 3 0
For stake $1$ to appear to have moved from $(3,3)$ to $(2,2)$, and stake $2$ from $(4,4)$ to $(3,3)$, you should draw the axes of the ship coordinate system so that its origin passes through $(1,1)$ in world coordinates. To create such a coordinate system, you should move yourself by x+1, y+1.
Sample 3
Input
1 1 90 2 1 2 0 0 -3 -1 -3
Output
-2 2 180
Combining rotation and translation gives this result.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
はむこ