How to tell whether or not 5 or more lines intersect
이전 댓글 표시

To the left is 4 intersections, and I am trying to control the number of line intersections in my loop. The intersections I am particularly interested are coming from the chords created from intersecting circles. I want to discard iterations that create of 5 or more line intersections. How do I do that?
n = 50; % Number of circles
m = 1000; % Number of points on circle
r_max = 85; % Maximum circle radius
r_min = 30; % Minimum circle radius
x_max = 720; % Uppermost x location of circle center
y_max = 360; % Uppermost y location of circle center
theta = 0:2*pi/m:2*pi; % Evaluated angles for circle
rad = r_max*rand(1,n); % Set radius array size
x_pos = x_max*rand(1,n); % Set x-position array size
y_pos = y_max*rand(1,n); % Set y-position array size
i = 1; % Looping value
j = 1; % Circle data pointer
while i<=n
j = i+1;
while j<=n % Partnering first circle with other circles
[xout,yout] = circcirc(x_pos(i),y_pos(i),rad(i),x_pos(j),y_pos(j),rad(j));
mapshow(xout,yout,'DisplayType','point','Marker','o')
plot(line([xout(1) xout(2)],[yout(1) yout(2)]))
axis([0 x_max 0 y_max]);
hold on
j = j+1;
end
i = i+1;
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!