how to get intersection point of two curves?

1 回表示 (過去 30 日間)
MANALI DODIYA
MANALI DODIYA 2018 年 11 月 10 日
コメント済み: Bruno Luong 2018 年 11 月 10 日
I want to get intersect point of two curve. I am use InterX for intersection of curves but I get error which is attacted below.
%program
syms Rb
R1=200;
R3=100;
R2=(R1+R3)/2;
theta=135;
Rb=solve((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);
plot(x1,y1,x2,y2)
hold on
q1=InterX([x1;y1],[x2;y2])
plot(x1,y1,x2,y2,P(1,:),P(2,:),'ro')
%error
140.5685985955217381715139492076
0.9117041268384028699662544052952
Error using symengine (line 59)
Array sizes must match.
Error in sym/privBinaryOp (line 903)
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in .* (line 238)
X = privBinaryOp(A, B, 'symobj::zip', '_mult');
Error in InterX (line 60)
S1 = dx1.*y1(1:end-1) - dy1.*x1(1:end-1);
Error in solve_equation (line 40)
q1=InterX([x1;y1],[x2;y2])

採用された回答

Star Strider
Star Strider 2018 年 11 月 10 日
Try this:
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);
plot(x1,y1,x2,y2)
hold on
% q1=InterX([x1;y1],[x2;y2])
[D,I] = pdist2([x1;y1]',[x2;y2]','euclidean','Smallest',1);
[minD,idx] = min(D);
P = [x1(I(idx)); y1(I(idx))];
plot(x1,y1,x2,y2,P(1,:),P(2,:),'ro')
It uses the pdist2 function to return the smallest distance between the points in the two sets, approximating the intersection.
  3 件のコメント
Star Strider
Star Strider 2018 年 11 月 10 日
I wanted to see if I could code an acceptable alternative using built-in functions.
Bruno Luong
Bruno Luong 2018 年 11 月 10 日
polyxpoly but it requires the Mapping toolbox. Without the toolbox you might end up doing what this FEX does.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFit Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by