The country of Byteland can be represented as a plane of infinite size. If you place a map of Byteland on the ground anywhere within the country, there will be exactly one "fixed point". This is the point on the plane that is at the exact same location as its representation on the map.
The map of Byteland has been created and placed by performing the following three transforms, one by one in order, on the original plane.
- 1. Scale it to a smaller size using a positive double scaling factor scale. Each point (x, y) in the original plane is transformed to (scale*x, scale*y).
- 2. Translate it by a given vector translate. Each point (x, y) is transformed to (x+translate[0], y+translate[1]).
- 3. Rotate it by a given angle rotate (in radians). Each point (x,y) is transformed to (x*cos(rotate)-y*sin(rotate), y*cos(rotate)+x*sin(rotate)).
In conclusion, the fixed point (x, y) for this configuration must satisfy the following two equations:
- (scale * cos(rotate) - 1) * x - scale * sin(rotate) * y = -translate[0] * cos(rotate) + translate[1] * sin(rotate)
- scale * sin(rotate) * x + (scale * cos(rotate) - 1) * y = -translate[0] * sin(rotate) - translate[1] * cos(rotate)
Solve the above equation and return the fixed point as a double[] containing exactly 2 elements, where the first element is the x-coordinate and the second element is the y-coordinate. There will always be exactly one unique solution.
|