How to find the distance between two points along a curve?

조회 수: 18 (최근 30일)
Sathiya
Sathiya 2024년 4월 26일
댓글: Mathieu NOE 2024년 4월 29일
I have a set of generated X and Y axis data, which have given a curved line. Now, I need to find the distance between two specified points along the curve, not the straight shortest distance between two points but along the curve path. Can someone help me finding this numerically?
  댓글 수: 7
Mathieu NOE
Mathieu NOE 2024년 4월 26일
dr represents only the increment of arc length (quite constant in this example)
now you need to do a sum of them - see my answer
Sathiya
Sathiya 2024년 4월 29일
@Sam Chak, dr here gives the shortest distance (displacement) between two points. For eg. lets say, I need the distance along the curve from 1st point and 50th point, this formula finds the straight distance between data points, not along the curve.

댓글을 달려면 로그인하십시오.

답변 (2개)

Mathieu NOE
Mathieu NOE 2024년 4월 26일
편집: Mathieu NOE 2024년 4월 26일
hello
try this
th = linspace(-pi/2, pi/2, 100);
R = 200;
X = R * sin(th) ; % X-coordinates
Y = R * cos(th) ; % Y-coordinates
dx = diff(X);
dy = diff(Y);
ds = sqrt(dx.^2+dy.^2); % increment of arc length
s = cumsum(ds); % integration => total arc length
s = [0 s]; % add first point : arc length = 0
% compute arc length between two points (defined by index position)
k1 = 25;
k2 = 59;
d = s(k2) - s(k1)
d = 215.7771
plot(X, Y, 'r.-',X(k1:k2), Y(k1:k2), 'db');
axis square
  댓글 수: 4
Torsten
Torsten 2024년 4월 27일
If you have an explicit equation of your curve, you can use the usual formula for arclength:
R = 200;
fun = @(t)sqrt((R*cos(t)).^2+(R*(-sin(t))).^2)
fun = function_handle with value:
@(t)sqrt((R*cos(t)).^2+(R*(-sin(t))).^2)
length_of_curve = integral(fun,-pi/2,pi/2)
length_of_curve = 628.3185
2*pi*R/2
ans = 628.3185
Sathiya
Sathiya 2024년 4월 29일
Yes, but I donot have a curve fitted equation for my curve.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2024년 4월 27일
  댓글 수: 2
Sathiya
Sathiya 2024년 4월 29일
@Mathieu NOE, understood. Now it is perfect to use then. Thanks Mathieu and all others who spent their time for my problem.
Mathieu NOE
Mathieu NOE 2024년 4월 29일
my pleasure !!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by