Improve the tri-ray intersection algorithm