{"ScriptPreparationCode":"var x = 490;\r\nvar y = 334;\r\nvar from = { x: 320, y: 160 }\r\nvar to = { x: 640, y: 480 }\r\n\r\nfunction belongsToRectangle(point, rectangle) {\r\n const from = { x: rectangle.x - 0.5*rectangle.width, y: rectangle.y - 0.5*rectangle.height };\r\n const to = { x: from.x \u002B rectangle.width, y: from.y \u002B rectangle.height };\r\n\r\n return (from.x \u003C= point.x) \u0026\u0026 (point.x \u003C= to.x) \u0026\u0026 (from.y \u003C= point.y) \u0026\u0026 (point.y \u003C= to.y);\r\n}\r\n\r\nfunction belongsToInfiniteLine(point, from, to) {\r\n const distance = (to.x - from.x)*(point.y - from.y) - (to.y - from.y)*(point.x - from.x);\r\n return Math.abs(distance) \u003C 1000;\r\n}","TestCases":[{"Name":"belongsToRectangle","Code":"const rectangle = {\r\n x: 0.5*(from.x \u002B to.x),\r\n y: 0.5*(from.y \u002B to.y),\r\n width: Math.max(Math.abs(from.x - to.x), 10),\r\n height: Math.max(Math.abs(from.y - to.y), 10),\r\n};\r\nbelongsToRectangle({ x, y }, rectangle);\r\n\r\n","IsDeferred":false},{"Name":"belongsToInfiniteLine","Code":"const rectangle = {\r\n x: 0.5*(from.x \u002B to.x),\r\n y: 0.5*(from.y \u002B to.y),\r\n width: Math.max(Math.abs(from.x - to.x), 10),\r\n height: Math.max(Math.abs(from.y - to.y), 10),\r\n};\r\nbelongsToInfiniteLine({ x, y }, from, to);","IsDeferred":false},{"Name":"belongsToInfiniteLine_fixed","Code":"belongsToInfiniteLine({ x, y }, from, to);","IsDeferred":false}]}