code: public static int findEdge(Poly node, Poly neighbour, MeshData tile, MeshData neighbourTile) {
  		// Compare indices first assuming there are no duplicate vertices
  		for (int i = 0; i < node.vertCount; i++) {
  			int j = (i + 1) % node.vertCount;
  			for (int k = 0; k < neighbour.vertCount; k++) {
  				int l = (k + 1) % neighbour.vertCount;
  				if ((node.verts[i] == neighbour.verts[l] && node.verts[j] == neighbour.verts[k])
  						|| (node.verts[i] == neighbour.verts[k] && node.verts[j] == neighbour.verts[l])) {
  					return i;
  				}
  			}
  		}
  		// Fall back to comparing actual positions in case of duplicate vertices
  		for (int i = 0; i < node.vertCount; i++) {
  			int j = (i + 1) % node.vertCount;
  			for (int k = 0; k < neighbour.vertCount; k++) {
  				int l = (k + 1) % neighbour.vertCount;
  				if ((samePosition(tile.verts, node.verts[i], neighbourTile.verts, neighbour.verts[l])
  						&& samePosition(tile.verts, node.verts[j], neighbourTile.verts, neighbour.verts[k]))
  						|| (samePosition(tile.verts, node.verts[i], neighbourTile.verts, neighbour.verts[k])
  								&& samePosition(tile.verts, node.verts[j], neighbourTile.verts, neighbour.verts[l]))) {
  					return i;
  				}
  			}
  		}
  		return -1;
  	}
docs: Find edge shared by 2 polygons within the same tile