34. Line-circle intersection

Suppose the line is defined by the following parametric equations:

Here, p0 = (p0x, p0y) is a point on the line and <vx, vy> is a vector pointing in the line's direction. If the second point on the line is p1 = (p1x, p1y), then you can use <p1x – p0x, p1y – p0x> as the vector.

If the circle is centered at point (cx, cy) and has the radius r, then the following equation defines the circle:

If we plug the line's parametric ...

Get The Modern C# Challenge now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.