Function rayIntersectRect

Ray intersection with a rectangle