intersections between circles and lines

조회 수: 6 (최근 30일)
gianluca scutiero
gianluca scutiero 2017년 3월 29일
댓글: KSSV 2017년 3월 29일
I have a matrix with the coordinates x,y of start of some lines and the matrix with coordinates x,y of end of each lines. I have also a vector with the centers of the circles and a vector with the radius. I would find the intersection points of these lines with circles. If a line intersects a circle, it is colored red. At the moment I wrote this code:
hold on
for i=1:3
theta = 0 : 0.01 : 2*pi;
radius = 3;
x = radius * cos(theta);
y =radius * sin(theta);
plot(x+xCenter(i), y+yCenter(i));
axis square;
grid on;
axis equal;
line(startxy,endxy)
end
For the moment I imposed a constant radius. You see a "cycle for" until 3 because I have imposed a vector with 3 rows, to try if the code works. Thanks for your help

답변 (1개)

KSSV
KSSV 2017년 3월 29일
  댓글 수: 2
gianluca scutiero
gianluca scutiero 2017년 3월 29일
I thank you for your response. The problem is that I use a function "line" that it is not supported by the function InterX
for i=1:3
t = 0:pi/200:2*pi;
r1 = 3; x1 = r1.*cos(t); y1 = r1.*sin(t);
r2 = line(startendx,startendy);
P = InterX([x1+xCenter(i);y1+yCenter(i)],[line(startendx,startendy)]);
plot(x1+xCenter(i),y1+yCenter(i),P(1,:),P(2,:),'ro')
axis equal
end
KSSV
KSSV 2017년 3월 29일
Why to use line? You have to input coordinates for the curves.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by