How to check the intersection of the line with a circle?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Beibit Sautbek
am 1 Jul. 2016
Bearbeitet: Thorsten
am 1 Jul. 2016
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154628/image.png)
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 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!