Intersection point(s) of a line and a circle.
INTERS = intersectLineCircle(LINE, CIRCLE);
Returns a 2-by-2-by-N array, containing on each row the coordinates of
an intersection point for each line-circle pair, i.e. INTERS(:,:,k)
contains the intersections between LINE(k,:) and CIRCLE(k,:).
If a line-circle pair does not intersect, the corresponding results are
set to NaN.
Example
% base point
center = [10 0];
% create vertical line
l1 = [center 0 1];
% circle
c1 = [center 5];
pts = intersectLineCircle(l1, c1)
pts =
10 -5
10 5
% draw the result
figure; clf; hold on;
axis([0 20 -10 10]);
drawLine(l1);
drawCircle(c1);
drawPoint(pts, 'rx');
axis equal;
See also
lines2d, circles2d, intersectLines, intersectCircles
References
http://local.wasp.uwa.edu.au/~pbourke/geometry/sphereline/
http://mathworld.wolfram.com/Circle-LineIntersection.html
Package: matgeom