Intersection between a circle and a line.
11 ビュー (過去 30 日間)
古いコメントを表示
Goal: To get the coordinates of line from every x-y point in the plane intersecting a circle with a given radius.
I am not sure if it is doing that. I was using tan before but I think tan2 works better.I wanted to use equations to solve y= mx and the circle equation but that seemed too complicated. Please let me know if you know of an easier way of doing this.
%calculates the intersection points of a line and a circle
x = -a:b;
y = (-a:b).';
u = numel(x);
Z = zeros(u*u,2);
theta = atan2((y-cy) ,(x-cx)); %cx,cy- center of the circle.
Zx = cx + r*cos(theta);
Zy = cy + r*sin(theta);
Z = [Zx(:) Zy(:)];
2 件のコメント
John D'Errico
2021 年 11 月 4 日
What you are doing is far more complex. Anyway, you CANNOT compute the coordinates of every point that falls inside a region, since there are infinitely many such points. Unless you are asking how to find the points on the line that intersect the perimeter of the circle.
So what is your goal? To get a list of points on the line inside the circle? Or just the two points where the line crosses the perimeter?
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!