{"ScriptPreparationCode":"function rand(min, max) {\r\n return Math.floor(Math.random() * (max - min \u002B 1)) \u002B min;\r\n}\r\n\r\nfunction angle(x, y) {\r\n let result = Math.atan(y / x);\r\n if (x \u003C 0) {\r\n result \u002B= Math.PI;\r\n } else if (y \u003C 0) {\r\n result \u002B= 2 * Math.PI;\r\n }\r\n return result;\r\n}\r\n\r\nfunction angle2(x, y) {\r\n if (x == 0)\r\n return (y == 0) ? 0 : (y \u003E 0 ? Math.PI/2 : -Math.PI/2)\r\n \r\n var atan_xy = Math.atan(y / x)\r\n if (x \u003E 0)\r\n return atan_xy\r\n else // x \u003C 0\r\n return atan_xy \u002B (y \u003C 0 ? -Math.PI : Math.PI)\r\n}\r\n\r\nfunction myAtan2(a, b)\r\n{\r\n var atan2val;\r\n if (b \u003E 0) {\r\n atan2val = Math.atan(a/b);\r\n }\r\n else if ((b \u003C 0) \u0026\u0026 (a \u003E= 0)) {\r\n atan2val = Math.atan(a/b) \u002B Math.PI;\r\n }\r\n else if ((b \u003C 0) \u0026\u0026 (a \u003C 0)) {\r\n atan2val = Math.atan(a/b) - Math.PI;\r\n }\r\n else if ((b = 0) \u0026\u0026 (a \u003E 0)) {\r\n atan2val = Math.PI / 2;\r\n }\r\n else if ((b = 0) \u0026\u0026 (a \u003C 0)) {\r\n atan2val = 0 - (Math.PI / 2 );\r\n }\r\n else if ((b = 0) \u0026\u0026 (a = 0)) {\r\n atan2val = 1000;\r\n }\r\n \r\n return atan2val;\r\n}\r\n\r\nfunction matan2(y, x){\r\n const c1 = Math.PI / 4;\r\n const c2 = Math.PI * 3 / 4;\r\n\r\n if (y == 0 \u0026\u0026 x == 0){\r\n return 0;\r\n }\r\n\r\n const abs_y = Math.abs(y);\r\n let angle;\r\n if (x \u003E= 0){\r\n angle = c1 - c1 * ((x - abs_y) / (x \u002B abs_y));\r\n } else {\r\n angle = c2 - c1 * ((x \u002B abs_y) / (abs_y - x));\r\n }\r\n\r\n if (y \u003C 0){\r\n return -angle;\r\n }\r\n\r\n return angle;\r\n}\r\n\r\nfunction atandd(y, x) {\r\n const ONEQTR_PI = Math.PI / 4.0;\r\n\tconst THRQTR_PI = 3.0 * Math.PI / 4.0;\r\n\tlet r, angle;\r\n\tlet abs_y = Math.abs(y) \u002B 0.0000000001;\r\n\t\r\n\tif ( x \u003C 0 ) {\r\n\t\tr = (x \u002B abs_y) / (abs_y - x);\r\n\t\tangle = THRQTR_PI;\r\n\t} else {\r\n\t\tr = (x - abs_y) / (x \u002B abs_y);\r\n\t\tangle = ONEQTR_PI;\r\n\t}\r\n\r\n\tangle \u002B= (0.1963 * r * r - 0.9817) * r;\r\n\t\r\n\tif ( y \u003C 0 )\r\n\t\treturn( -angle );\r\n\telse\r\n\t\treturn( angle );\r\n}","TestCases":[{"Name":"native","Code":"var xO = rand(1, 1000);\r\nvar yO = rand(1, 1000);\r\n\r\nMath.atan(yO, xO);","IsDeferred":false},{"Name":"alt","Code":"var xT = rand(1, 1000);\r\nvar yT = rand(1, 1000);\r\n\r\nangle(xT, yT);","IsDeferred":false},{"Name":"alt2","Code":"var xD = rand(1, 1000);\r\nvar yD = rand(1, 1000);\r\n\r\nangle2(xD, yD);","IsDeferred":false},{"Name":"alt3","Code":"var xC = rand(1, 1000);\r\nvar yC = rand(1, 1000);\r\n\r\nmyAtan2(xC, yC);","IsDeferred":false},{"Name":"alt4","Code":"var xZ = rand(1, 1000);\r\nvar yZ = rand(1, 1000);\r\n\r\nmatan2(xZ, yZ);","IsDeferred":false},{"Name":"alt5","Code":"var xU = rand(1, 1000);\r\nvar yU = rand(1, 1000);\r\n\r\natandd(yU, xU)","IsDeferred":false}]}