How to check the intersection of the line with a circle?
2 次查看(过去 30 天)
显示 更早的评论
I have a line with points A[5,60] and B[60,60]. Also I have 10 circles with x and y positions which is shown in matrix C below, the radius of each circle is r=1:
C= [46.5816 21.1706
29.2028 24.7608
23.8874 15.4974
19.3820 66.0560
36.2145 57.9523
14.4454 90.1348
34.2785 59.8094
37.0270 99.0752
49.1183 68.0090
31.6019 30.9405];
So, How Can I check that any circle's radius intersects with the given line? And I need to put condition that If any circle intersects with line, cancel that circle from the matrix C.
I plot lines and circles as shown in Figure below:
According to the figure we can see that the circle (34.2785 59.8094)was intersected with line AB, so I need to cancel that point from the matrix C, and the results should be like that: C=
46.5816 21.1706
29.2028 24.7608
23.8874 15.4974
19.3820 66.0560
36.2145 57.9523
14.4454 90.1348
37.0270 99.0752
49.1183 68.0090
31.6019 30.9405
I used these code to plot 10 circles:
r=1; % radius of circles
th = linspace(0,2*pi) ;
x = r*cos(th) ;
y = r*sin(th) ;
% Loop for each circle
for i = 1:10 %10 is number of circles
xc = C(i,1)+x ;
yc = C(i,2)+y ;
hold on
plot(xc,yc) ;
end
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!