{"ScriptPreparationCode":"function pointDistance(\r\n fromX,\r\n fromY,\r\n toX,\r\n toY,\r\n) {\r\n const diffX = toX - fromX;\r\n const diffY = toY - fromY;\r\n const distance = Math.sqrt(diffX ** 2 \u002B diffY ** 2);\r\n return [distance, diffX / distance, diffY / distance];\r\n}\r\n\r\nfunction rectDistance(xA, yA, radiusA, xB, yB, radiusB) {\r\n const leftA = xA - radiusA;\r\n const rightA = xA \u002B radiusA;\r\n const topA = yA - radiusA;\r\n const bottomA = yA \u002B radiusA;\r\n\r\n const leftB = xB - radiusB;\r\n const rightB = xB \u002B radiusB;\r\n const topB = yB - radiusB;\r\n const bottomB = yB \u002B radiusB;\r\n\r\n const xDistance = leftB \u003E rightA ? leftB - rightA : leftA \u003E rightB ? leftA - rightB : 0;\r\n\r\n const yDistance = topB \u003E bottomA ? topB - bottomA : topA \u003E bottomB ? topA - bottomB : 0;\r\n\r\n return xDistance \u003E yDistance ? xDistance : yDistance;\r\n}\r\n","TestCases":[{"Name":"pointDistance","Code":"for (let i = 0, len = 1_000_000; i \u003C len; i\u002B\u002B) {\r\n const d = pointDistance(i \u002B 1.5, i \u002B 2.5, i \u002B 3.5, i \u002B 4.5);\r\n}","IsDeferred":false},{"Name":"rectDistance","Code":"for (let i = 0, len = 1_000_000; i \u003C len; i\u002B\u002B) {\r\n const d = rectDistance(i \u002B 1.5, i \u002B 2.5, 4, i \u002B 3.5, i \u002B 4.5, 5);\r\n}","IsDeferred":false}]}