Borrar filtros
Borrar filtros

Searching for line and circle intersection.

10 visualizaciones (últimos 30 días)
Miro Mitev
Miro Mitev el 8 de Ag. de 2016
Comentada: Miro Mitev el 10 de Ag. de 2016
Hello,
I have two circles and a line that connects the centers. I am trying to find only the closest intersections of the line and the circles(A and B) , but the "linecirc" function gives me all the four.
And this is my code:
Center1=[0.68,3.17];
Center3=[3.82,0.28];
Xline1_3=[0.68 3.82];
Yline1_3=[3.17 0.28];
p1_3=polyfit(Xline1_3,Yline1_3,1);
[X_L1_3_C1,Y_L1_3_C1] = linecirc(p1_3(:,1),p1_3(:,2),0.68,3.17,2);
[X_L1_3_C3,Y_L1_3_C3] = linecirc(p1_3(:,1),p1_3(:,2),3.82,0.28,1);
%http://www.mathworks.com/matlabcentral/fileexchange/2876-draw-a-circle
s1=circle(Center1,2,1000);
hold on
s3=circle(Center3,1,1000);
hold on
plot(Xline1_3,Yline1_3)
hold on
scatter(X_L1_3_C1,Y_L1_3_C1)
scatter(X_L1_3_C3,Y_L1_3_C3)
  2 comentarios
Pawel Ladosz
Pawel Ladosz el 9 de Ag. de 2016
Does it have to work on this case only or on any generic case?
Miro Mitev
Miro Mitev el 10 de Ag. de 2016
I need it in any case :)

Iniciar sesión para comentar.

Respuesta aceptada

Thorsten
Thorsten el 9 de Ag. de 2016
Editada: Thorsten el 9 de Ag. de 2016
If P11 and P12 are the intersection points with circle 1, and P21, P22 are those with circle 2, you compute the distances between each pair
d(P11, P21)
d(P11, P22)
d(P12, P21)
d(P12, P22)
an then select the points with the smallest distance. Note that for some configurations, e.g., two concentric circles and a line through the common center, you get two pairs with the same minimal distance.
  1 comentario
Miro Mitev
Miro Mitev el 10 de Ag. de 2016
Hi Thorsten, Yes I already did that. I was thinking if there is some shorter way but this one also works for me. Thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by