If needed, this function can be modified to take two additional coorinates that will be set to the intersection points.