15. 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 Improving your C# Skills now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.