find points of intersection circle with line

6 vues (au cours des 30 derniers jours)
Madalina Lupu
Madalina Lupu le 26 Mai 2020
Commenté : Madalina Lupu le 26 Mai 2020
Hello,
I need to find and plot the points of intersection of the circle with each rectangle. Could you please help me?
I drew the circle like this:
pos = [0 0 3 3];
rectangle('Position',pos,'Curvature',[1 1])

Réponse acceptée

KSSV
KSSV le 26 Mai 2020
clc; clear all ;
C = [1.5 1.5] ; % center of cricle
r = 1.5 ; % radius of circle
%
x = 0:1:3 ;
y = 0:1:3 ;
[X,Y] = meshgrid(x,y) ;
%
th = linspace(0,2*pi) ;
xc = C(1)+r*cos(th) ;
yc = C(2)+r*sin(th) ;
L1 = [xc;yc] ;
% GEt intersecdtion points
% along X
[m,n] = size(X) ;
for i = 1:m
L2 = [X(i,:) ; Y(i,:)] ;
P{i} = InterX(L1,L2)
end
for i = 1:n
L2 = [X(:,i) Y(:,i)]' ;
Q{i} = InterX(L1,L2) ;
end
P = cell2mat([P Q]) ;
plot(xc,yc,'b') ;
hold on
plot(X,Y,'r')
plot(X',Y','r')
plot(P(1,:),P(2,:),'*k')
  1 commentaire
Madalina Lupu
Madalina Lupu le 26 Mai 2020
Thank you! It works very well!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Polar Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by