{"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}","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":"al3","Code":"var xC = rand(1, 1000);\r\nvar yC = rand(1, 1000);\r\n\r\nmyAtan2(xC, yC);","IsDeferred":false}]}