The figure below shows a ray of light traveling from the point A (in medium such as water) to the point B (in medium such as air). The perpendicular distance from A to the line separating the two media is a, and the perpendicular distance from B is b. You can take the horizontal distance between A and B to be x. The point P is where the ray of light hits the interface. The angle of incidence is θi and the angle of refraction is θr. They are determined by an important principle of physics discovered by Fermat. According to Fermat's principle, light travels along the path that minimizes the time of travel. Assume the velocity of light in the two media to be v1 and v2 respectively. Find the relationship between θi and θr.