Filter löschen
Filter löschen

Finding distance between two curves at diffrent points

22 Ansichten (letzte 30 Tage)
Praveen Patnaik
Praveen Patnaik am 12 Mär. 2020
Kommentiert: darova am 14 Feb. 2021
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 Kommentare
darova
darova am 12 Mär. 2020
Do you have data of curves? Or only image?
Praveen Patnaik
Praveen Patnaik am 12 Mär. 2020
It is just a general concept.... These are just images. Suppose the function of these curves are defined . Then how will we do it???

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

darova
darova am 12 Mär. 2020
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 Kommentare
Ron Herman
Ron Herman am 17 Nov. 2020
Bearbeitet: Ron Herman am 17 Nov. 2020
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 am 14 Feb. 2021
DId you get the answer?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Geometric Transformation and Image Registration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by