Sunday, 23 February 2014

Determining if a line intersects a circle

Initiate Ivan has just been hired as an intern. He is tasked with solving a seemingly simple problem.

Given the two points that define a line and the centre and and radius of a circle, Ivan is to determine whether the line intersects the circle. After hours of thinking, he came up with an approach. Taking one of the two points of the line as the origin, he plans to first find the angle formed by the line with the x-axis. Then he finds the angle formed by the line joining the centre of the circle and the "origin" earlier. He reasons that if the two angles are reasonably close, he can conclude that the line does intersect the circle.

Ivan's mentor comes around, looks at his solution, and smiles. "That's pretty interesting! But it seems to need more work..."

What is lacking in Ivan's solution?

No comments:

Post a Comment