Statistics

Problem Statement for "FixedPoint"

Problem Statement

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. 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. 2. Translate it by a given vector translate. Each point (x, y) is transformed to (x+translate[0], y+translate[1]).
  3. 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.

Definition

Class:
FixedPoint
Method:
find
Parameters:
double, double[], double
Returns:
double[]
Method signature:
double[] find(double scale, double[] translate, double rotate)
(be sure your method is public)

Notes

  • A return value with an absolute or relative error less than 1.0E-9 is considered correct.

Constraints

  • scale will be between 0.1 and 0.9, inclusive.
  • translate will contain exactly 2 elements.
  • Each element of translate will be between -1000 and 1000, inclusive.
  • rotate will be between -1000 and 1000, inclusive.

Examples

  1. 0.5

    {1, 0}

    1.5707963267948966

    Returns: {-0.39999999999999997, 0.8 }

    After the scaling transform, (-0.4, 0.8) becomes (-0.2, 0.4). After the translation transform, (-0.2, 0.4) becomes (0.8, 0.4). Finally, after the rotation transform, (0.8, 0.4) becomes (-0.4, 0.8), which is the original point.

  2. 0.5

    {2, 0}

    0

    Returns: {4.0, 0.0 }

    (4, 0) -> (2, 0) -> (4, 0) -> (4, 0) The three "->"s represent scaling, translation, and rotation, respectively.

  3. 0.1

    {0, 0}

    2

    Returns: {0.0, -0.0 }

    (0, 0) never moves whenever the translate vector is (0, 0).

  4. 0.5

    {1, 2}

    0.785398163397

    Returns: {-2.223469992542095, 2.065452845425795 }

  5. 0.67059

    {22.25, -872.37}

    567.39

    Returns: {425.11300659471317, 471.94994915177386 }

  6. 0.40476

    {-744.22, 915.64}

    518.19

    Returns: {447.1242430810225, -714.1058435593618 }

  7. 0.75964

    {180.60, 522.32}

    -42.40

    Returns: {-414.8904721371243, -139.34809075302874 }

  8. 0.64484

    {-697.86, -287.05}

    -328.19

    Returns: {70.72775145088025, 663.5200060850929 }

  9. 0.61299

    {-800.80, -6.67}

    960.29

    Returns: {103.58384666556391, 917.4460217866235 }

  10. 0.56463

    {-864.29, 835.16}

    877.36

    Returns: {818.3805706231111, -178.05024348347297 }

  11. 0.43173

    {-634.97, -26.07}

    876.86

    Returns: {431.0477380762937, 128.66414641407047 }

  12. 0.39114

    {-538.98, 626.18}

    -764.23

    Returns: {70.17347298583971, -632.603789531771 }

  13. 0.50822

    {-561.37, -652.10}

    -671.31

    Returns: {745.9758481027606, -706.5837079413874 }

  14. 0.33726

    {449.24, 410.30}

    -516.70

    Returns: {283.63536570189666, -521.0467097981498 }

  15. 0.40234

    {103.27, -120.82}

    -316.32

    Returns: {-123.886045552062, 18.644758824893213 }

  16. 0.48959

    {963.16, 214.79}

    3.03

    Returns: {-656.475904967868, -95.51498480526274 }

  17. 0.78015

    {-957.82, -206.65}

    -21.65

    Returns: {513.3869059767893, 219.68597154204062 }

  18. 0.81949

    {-423.36, 102.60}

    -244.83

    Returns: {-1264.1830309576546, -1053.9441769922137 }

  19. 0.16395

    {997.29, 638.06}

    -67.10

    Returns: {-1000.3768034020889, 446.7009382471021 }

  20. 0.44889

    {-951.79, 536.38}

    247.13

    Returns: {261.12612148403247, -811.1700207316197 }

  21. 0.67224

    {606.59, 775.04}

    -996.08

    Returns: {-416.1604615738009, -419.98736118259455 }

  22. 0.84034

    {-611.31, -590.09}

    660.53

    Returns: {957.4498000825439, -667.6197033183715 }

  23. 0.24786

    {835.35, 739.83}

    315.87

    Returns: {-934.1800934619135, 478.17715615763854 }

  24. 0.74899

    {-111.40, 31.70}

    766.76

    Returns: {-333.50855203393286, -167.33272567676963 }

  25. 0.88795

    {289.89, -223.57}

    -449.26

    Returns: {-152.77872634240694, 119.41552220290656 }

  26. 0.42808

    {-773.83, 903.40}

    -91.95

    Returns: {97.335360900198, -893.31796025482 }

  27. 0.54129

    {951.41, -790.50}

    -337.15

    Returns: {-193.98637112494228, 881.4629264330196 }

  28. 0.33505

    {-884.80, 727.09}

    888.11

    Returns: {138.65561622729078, -925.9383792720727 }

  29. 0.78075

    {-998.25, -480.66}

    -236.98

    Returns: {753.2046831258332, -258.68811910226884 }

  30. 0.499772092

    {26.082681466, 962.386641885}

    -755.838446858

    Returns: {589.7828538788569, -507.42333253851575 }

  31. 0.759475721

    {534.592290209, 468.702880315}

    -735.788866638

    Returns: {813.0624584775637, -832.4609473422527 }

  32. 0.355661761

    {518.234513856, -131.452097527}

    139.703496754

    Returns: {-2.9345110054410313, 519.9392447098406 }

  33. 0.729412140

    {-534.613249859, 345.372821192}

    -311.695306695

    Returns: {221.06237100236024, -320.8337446115807 }

  34. 0.762175791

    {306.467129988, -557.669407351}

    257.283172247

    Returns: {-892.4151134622995, -1465.4385473767143 }

  35. 0.459457192

    {862.359383465, -568.793265067}

    -530.049737146

    Returns: {-770.3048642568506, -22.447861618471073 }

  36. 0.211715714

    {831.764674134, -845.581045123}

    -203.063493974

    Returns: {-1057.39403804481, -183.08923686668422 }

  37. 0.256468880

    {883.659691868, 529.044228724}

    -37.067853604

    Returns: {267.78609034261694, 1247.3861561557783 }

  38. 0.107275488

    {584.710970808, -963.899257795}

    307.428072598

    Returns: {57.141420935797534, -1245.0954284000156 }

  39. 0.661528991

    {482.435204443, -947.388869109}

    -244.756251833

    Returns: {2440.139840366085, -855.5950011778343 }

  40. 0.261177843

    {-532.124093440, -187.110607542}

    324.752233062

    Returns: {137.7385698733655, 480.60959232560646 }

  41. 0.433911159

    {-193.534061340, 196.062549339}

    -13.774061556

    Returns: {225.57475693885098, 188.03417546136345 }

  42. 0.712444889

    {-192.026777700, -693.686135742}

    -16.700130377

    Returns: {359.7081156366816, 311.7025566022317 }

  43. 0.688697187

    {760.679904658, 387.182562992}

    221.768783409

    Returns: {-595.7680378272262, 189.7477444838111 }

  44. 0.226426690

    {-200.071657573, 245.277349379}

    -471.699607026

    Returns: {-38.51101667689064, 392.04311727145597 }

  45. 0.606465231

    {381.539535612, -483.096651846}

    -312.354807974

    Returns: {91.12722652650146, 470.6957331985824 }

  46. 0.720379578

    {736.304176044, -561.357934848}

    -107.700128291

    Returns: {-822.0155476473718, -857.4088378303646 }

  47. 0.159914276

    {-803.221095931, -927.105850544}

    -660.794254514

    Returns: {-1234.572372228999, 455.00447357471944 }

  48. 0.115791473

    {635.058644605, -374.243040747}

    -979.178106997

    Returns: {658.6366041088235, 421.96297521671863 }

  49. 0.478011911

    {-890.771121398, -234.671107455}

    528.227924428

    Returns: {-769.8019071743955, -1319.3321666278478 }

  50. 0.793603804

    {-103.619515565, -47.168755403}

    -880.137503898

    Returns: {-136.12852290888696, 194.1538407490722 }

  51. 0.338687652

    {-113.284383052, -981.418396877}

    663.627867351

    Returns: {-341.19991069340125, 699.9947969566092 }

  52. 0.748273492

    {-917.225293199, -981.704750956}

    -728.809223910

    Returns: {-2951.7354409764075, -4386.110723037526 }

  53. 0.696574143

    {-84.488780484, 688.603298495}

    -994.617921452

    Returns: {389.68324789879796, -318.11700369987716 }

  54. 0.765615021

    {2.142064694, -771.938167184}

    -753.437196085

    Returns: {1446.5398739194793, -245.5582914806809 }

  55. 0.5

    {1.0, 2.0 }

    0.785398163397

    Returns: {-2.223469992542095, 2.065452845425795 }

  56. 0.5

    {1.0, 1.0 }

    0.0

    Returns: {2.0, 2.0 }

  57. 0.5

    {1.0, 2.0 }

    10.785398163397

    Returns: {0.8551547535059876, -1.642126484914687 }

  58. 0.9

    {1.0, 1.0 }

    0.0

    Returns: {10.000000000000004, 10.000000000000004 }

  59. 0.7071067811865476

    {1.0, 2.0 }

    0.0

    Returns: {3.4142135623730954, 6.828427124746191 }


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: