calculating direction of invasion