Refactor intersection calculation between paths and shapes