Intersection between ellipse and circle
이전 댓글 표시
I'm trying to write a code to find the intersection between an ellipse and a circle. This is what I've got so far:
%ellipse
e=0.284576477148; %eccentricity
a=0.803468308684*150*10^6; c=e*a; b=sqrt(a^2-c^2); %parameters of ellipse
beta=linspace(0,2*pi,100);
X=a*cos(beta)-b*sin(beta)+c; %ellipse is shifted
Y=a*cos(beta)+b*sin(beta);
plot(X,Y,'r'), hold on
%circle
r=150*10^6; %radius
x=r*cos(beta);
y=r*sin(beta);
plot(x,y,'b')
axis square
z=[];
for i=1:length(beta)
f1=a*cos(beta(i))-b*sin(beta(i))+c-r*cos(beta(i)); %X coordinates of the ellipse - x coordinates of the circle
f2=a*cos(beta(i))+b*sin(beta(i))-r*sin(beta(i)); %Y coordinates - y coordinates
if f1<=0.1*10^-20 && f2<=0.1*10^-20
z=[z beta(i)];
end
end
for k=1:length(z)
p=r*cos(z(k));
q=r*sin(z(k));
plot(p,q,'*'), hold on
end
I'm trying to look for the angle beta where the curves intersect by looking for the value of beta that makes the expressions f1 and f2 close to zero. However, this code finds too many points that are actually quite far from the intersections, no matter how low I set the tolerance (if I set it to 0 no points are shown). What am I doing wrong? Thanks!
댓글 수: 2
darova
2019년 11월 11일
What about graphical solution? polyxpoly or intersections
Ludovica Lanzieri
2019년 11월 11일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
