
There are two steps to detect the collision of sphere and rectangle:
1. Find the point within rectangle which is the nearest point to sphere
2. Check the nearest point is in sphere or not. If it is in sphere, they collide each other.
To find the nearest point: