let res = -Infinity; for (let i = 0; i < points.length; i++) { const point1 = points[i]; for (let j = i + 1; j < points.length; j++) { const point2 = points[j]; for (let k = j + 1; k < points.length; k++) { const point3 = points[k]; const a = getDistance(point1, point2), b = getDistance(point1, point3), c = getDistance(point2, point3);
const p = (a + b + c) / 2; const s = Math.sqrt( p * Math.abs(p - a) * Math.abs(p - b) * Math.abs(p - c) ); res = Math.max(s, res); } } } return res; };
var largestTriangleArea = function (points) { const n = points.length; let ret = 0.0; for (let i = 0; i < n; i++) { for (let j = i + 1; j < n; j++) { for (let k = j + 1; k < n; k++) { ret = Math.max( ret, triangleArea( points[i][0], points[i][1], points[j][0], points[j][1], points[k][0], points[k][1] ) ); } } } return ret; };