Skip to main content
1-Visitor
July 26, 2019
Solved

How to traverse a curve

  • July 26, 2019
  • 1 reply
  • 6693 views

Dear all,

 

I have a set of close points (every 20 mm for a 100m long curve) which I can import into Mathcad and use linterp to create a temporary function. 

 

But when I need to call the function, I need the input to be the length of the curve. For example,

 

If I have a function y = sin(x) and I need to have a function which calculates the slope (tangent) at a distance 'd' but the distance is measured along the length of the curve sin(x) and not at x=d..

 

Is there any straightforward way of doing this ? I can think of one crude way (slowly start traversing the curve in small increments of x and keep on adding distance between y(x) and y(x+dx) until 'd' is reached and thereby now we know the (x,y) coordinates for the function and go from there). But I have to use this routine thousands of times and I don't think my method is efficient at all. 

Please suggest ?

 

Warm Regards,

Aravind.

 

 

Best answer by Werner_E

If you already turned your points into a function (via linterp, splines, or whatever) you may use the integral formula for curve length to do the job.

You are best off if you post a worksheet with your data and your attempts and maybe some concrete numerical examples to show what exactly you are looking for.

As far as I understand you try to derive a parameter representation of a function with curve length as parameter, when a cartesian representation is given.

1 reply

Werner_E25-Diamond IAnswer
25-Diamond I
July 26, 2019

If you already turned your points into a function (via linterp, splines, or whatever) you may use the integral formula for curve length to do the job.

You are best off if you post a worksheet with your data and your attempts and maybe some concrete numerical examples to show what exactly you are looking for.

As far as I understand you try to derive a parameter representation of a function with curve length as parameter, when a cartesian representation is given.

adnn1-VisitorAuthor
1-Visitor
July 26, 2019

Awesome ! I didn't know that there is a simple integral which gives length of curve 🙂      (1 + (dy/dx)^2)^0.5

 

This would work perfectly, except I need to use it in reverse (I know the length and I need to find the x). I think since it's just one equation+variable, given+find block should be fast enough to use in a loop. 

 

Thanks a lot Werner ! 

 

Sorry for not giving any data (Actually I am yet to start making the sheet and was brainstorming ideas on how to achieve my goal and I thought my solution was just too bad so decided to ask for help right away )

25-Diamond I
July 26, 2019

Yes , a solve block would give you the inverse you need.

Something like this:

B.png

Depending on the function you use I guess its better not to use a constant guess value but rather make the guess for x dependent on the curve length in some way as shown in the file. But that depends on the function you have. You may give it a try with a constant guess at first.

Mathcad 15 sheet attached.

EDIT: One additional remark. As you are looking for the derivatives I think you should not use linear interpolation but rather spline interpolation for smooth results.

If you stay with linear interpolation, then determining the x-value from a given "curve" length could be programmed easier and exact as it would just mean to determine the length of line segments or parts of them.

Furthermore the "derivative" would be constant between two of your points and not defined at the points themselves (or you may calculate the mean value for them).

BTW, the time consuming part in my approach is not the solve block but rather the numeric derivation.