how to generate curve up to particular point?
조회 수: 2 (최근 30일)
이전 댓글 표시
I need to generate profile which is combination of multiple curves. I get intersecting point of different curve. I need to remove extra green curve after intersection point.
댓글 수: 0
답변 (1개)
Star Strider
2018년 11월 16일
syms Rb
R1=200;
R3=100;
R2=(R1+R3)/2;
theta=135;
Rb=vpasolve((tan(acos(Rb/R1))-tan(acos(Rb/R2))-(acos(Rb/R1))+(Rb/R2))*(180/pi)==180-theta,Rb);
disp(Rb)
alpha=(tan(acos(Rb/R2))-acos(Rb/R2))*(180/pi);
% disp(alpha)
t=linspace(0,2*pi);
x1=Rb*(cos(t-alpha)+t.*sin(t-alpha));
y1=Rb*(sin(t-alpha)-t.*cos(t-alpha));
x2=R1*cos(t);
y2=R1*sin(t);
x1 = double(x1);
y1 = double(y1);
x2 = double(x2);
y2 = double(y2);
[in,on] = inpolygon(x1, y1, x2, y2); % Find (x1,y1) In Or On (x2,y2)
inon = in | on;
figure
plot(x1,y1, x2, y2)
hold on
hinon = plot(x1(inon),y1(inon), 'pg'); % (x1,y1) In Or On (x2,y2)
hout = plot(x1(~inon),y1(~inon), 'pm') % (x1,y1) Outside (x2,y2)
hold off
legend([hinon,hout], '(x1,y1) In | On (x2,y2)', '(x1,y1) Outside (x2,y2)', 'Location','SE')
I am not certain what you intend with ‘after intersection point’, so I included both options (inside and outside the ellipse), and displayed them with different-colored pentagrams.
댓글 수: 2
Star Strider
2018년 11월 17일
I cannot find a numeric or analytic expression to solve for the intersection that produces reasonable values for both functions, using solve or fsolve.
I would increase the resolution (here ‘N’) in the linspace call to get as close as you can:
N = 1E+5;
t = linspace(0,2*pi,N);
and then go with the smallest distance (as previously), or use Bruno Luong’s suggestion on the File Exchange contribution he cited in his Comment in your earlier Question.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!