フィルターのクリア

Finding distance between two curves at diffrent points

22 ビュー (過去 30 日間)
Praveen Patnaik
Praveen Patnaik 2020 年 3 月 12 日
コメント済み: darova 2021 年 2 月 14 日
1.Suppose the curves are defined, how do i find the distance between two curves at diffrent points.
Curve 1= f(x)
curve 2 = g(x)
Do i need to define points on one of the curve to find out the required distance???
For exmple I am posting an image.
Important note-
I need distance at diffrent points between two curves and not single point nor am I looking for minimum distance between curves.
Perpendicular distance from tangent as shown in image.
  2 件のコメント
darova
darova 2020 年 3 月 12 日
Do you have data of curves? Or only image?
Praveen Patnaik
Praveen Patnaik 2020 年 3 月 12 日
It is just a general concept.... These are just images. Suppose the function of these curves are defined . Then how will we do it???

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

採用された回答

darova
darova 2020 年 3 月 12 日
With use of polyxpoly
clc,clear
x = 0:0.1:10;
y1 = sin(x); % data 1
y2 = sqrt(x); % data 2
% index of point
ix = 70;
x0 = x(ix);
y0 = y2(ix);
% tangent vector
dy = diff(y2(ix:ix+1));
dx = diff(x(ix:ix+1));
% normal vector
xv = [0 dy]*50+x0;
yv = [0 -dx]*50+y0;
% intersection point
[xc,yc] = polyxpoly(xv,yv,x,y1);
plot(x,y1,x,y2)
hold on
plot(xv,yv)
plot(xc,yc,'or')
hold off
axis equal
  28 件のコメント
Ron Herman
Ron Herman 2020 年 11 月 17 日
編集済み: Ron Herman 2020 年 11 月 17 日
I need the following output
I am unable to get the following output for some reason I an unable to draw horizontal line in all 3 points
(horizontal line from middle point is not getting constructed)
For some reason index =50 or at ind=50 no line is being constructed. I donot the reason for this yet.
clc,clear
r = 10; % arc length
R = 55; % radius of a circle
aa = 60*pi/180; % arc angle
ap = 0*pi/180; % arc position angle
k=0;
%xa=60;
% a=10;
% b=50;
ind=[25 50 75];
t = linspace(0,pi);
[x,y] = pol2cart(t,R); % circle data
t1 = linspace(0,aa)-aa/2+ap;
[x1,y1] = pol2cart(t1,r); % arc data
xc=65;
yc=15;
%shifting the arc mid point to (65,15)
mp=length(x1)/2;
delx=xc-x1(mp);
dely=yc-y1(mp);
x1=x1+delx;
y1=y1+dely;
XC = ind*nan;
YC = ind*nan;
for i = 1:length(ind)
ix = ind(i);
x0 = x1(ix);
y0 = y1(ix);
% minor difference
dy = diff(y1(ix:ix+1));
dx = diff(x1(ix:ix+1));
% horizontal
xv = [dx -dx]*1500+x0;
yv = [0 0]*1500+y0;
%line(xv,yv)
% intersection point
[xc,yc] = polyxpoly(xv,yv,x,y);
if ~isempty(xc)
XC(i) = xc
YC(i) = yc
end
end
plot(x,y,x1,y1)
hold on
plot([XC;x1(ind)],[YC;y1(ind)],'.-r') % x1(ind)& y1(ind)are points on the curve
hold off % XC and YC are intersection points
axis equal
darova
darova 2021 年 2 月 14 日
DId you get the answer?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeometric Transformation and Image Registration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by