export const isPointInsidePolygon = (
    point: [number, number],
    polygon: [number, number][]
) => {
    let inside = false;
    for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
        const xi = polygon[i][0],
            zi = polygon[i][1];
        const xj = polygon[j][0],
            zj = polygon[j][1];

        const intersect =
            // eslint-disable-next-line no-mixed-operators
            zi > point[1] !== zj > point[1] &&
            point[0] < ((xj - xi) * (point[1] - zi)) / (zj - zi + 0.000001) + xi;

        if (intersect) inside = !inside;
    }
    return inside;
};