function _PointToLine(
point,
lines
) {
const [x, y] = point;
const [x1, y1] = lines[0];
const [x2, y2] = lines[1];
const length = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
const areas = Math.abs((x1 - x) * (y2 - y) - (y1 - y) * (x2 - x));
return areas / length;
}
function _isPointInLine(
coordinates,
point,
projection,
lineWidth
) {
if (coordinates.length <= 1) return false;
const lineArr = coordinates.map(projection);
for (let i = 1; i < lineArr.length; i++) {
if (
this._PointToLine(point, [lineArr[i], lineArr[i - 1]]) <
lineWidth / 2
) {
return true;
}
}
return false;
}
console.time("")
console