Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
arc length

Subject: arc length

From: bo

Date: 7 Apr, 2010 04:39:05

Message: 1 of 8

Hi everyone,

How to calculate arc length between 2 different radius?As I only know, the arc length inside circle is r*(theta2-theta1).

Bo

Subject: arc length

From: Roger Stafford

Date: 7 Apr, 2010 06:39:08

Message: 2 of 8

"bo " <bobpong1979@hotmail.com> wrote in message <hph299$vn$1@fred.mathworks.com>...
> Hi everyone,
>
> How to calculate arc length between 2 different radius?As I only know, the arc length inside circle is r*(theta2-theta1).
>
> Bo

  I interpret your question this (long-winded) way. You would like to find the arc length along a curve, not a perfect circle, in terms of its varying radius of curvature and varying angle of a normal to the curve. If that is what you are asking, the answer would be a conditional yes, provided you know just how these two quantities vary - their full history of variation - all along the curve.

  One can write an infinitesimal version of the equation you gave as

 ds = r*dt

where s is arc length, r is the radius of curvature and t (short for theta) is the angle of a normal to the curve with respect to, say, the x-axis. We understand here that s is considered increasing, that t is to be measured positive in the counterclockwise rotational sense, and that the radius is considered positive if the curve is bending to the left while negative if bending to the right. That means you could in principle compute the arc length along a curve as the integral with respect to angle t of the varying radius of curvature, r, with this convention for its sign.

  However, it must be said that it is unusual to possess this kind of information about curvature and angle along a curve without already knowing arc length too, so such a formula would not ordinarily be of much practical use.

  Certainly you cannot determine arc length knowing only the angles and radii at the two endpoints of a curve. As mentioned above, you must know these quantities as they vary all along the curve in order to compute such an integral. In particular, if the curve bends first to the left and then to the right, arriving at the same angle as initially, then obviously endpoint information alone would not tell you anything about the arc length traveled.

Roger Stafford

Subject: arc length

From: Walter Roberson

Date: 7 Apr, 2010 14:49:39

Message: 3 of 8

bo wrote:

> How to calculate arc length between 2 different radius?As I only know,
> the arc length inside circle is r*(theta2-theta1).

In addition to what Roger wrote: note that the integration that he
suggests is correct in theory, but has the technical problem that closed
forms for the calculation of arc length are known for only a relatively
small number of shapes. For example there is a whole branch of calculus
dealing with integration along ellipses, which there is no closed
formula for, even though we think of them as being such a minor
variation of circles.

Subject: arc length

From: John D'Errico

Date: 7 Apr, 2010 16:30:21

Message: 4 of 8

Walter Roberson <roberson@hushmail.com> wrote in message <hpi624$rn0$1@canopus.cc.umanitoba.ca>...
> bo wrote:
>
> > How to calculate arc length between 2 different radius?As I only know,
> > the arc length inside circle is r*(theta2-theta1).
>
> In addition to what Roger wrote: note that the integration that he
> suggests is correct in theory, but has the technical problem that closed
> forms for the calculation of arc length are known for only a relatively
> small number of shapes. For example there is a whole branch of calculus
> dealing with integration along ellipses, which there is no closed
> formula for, even though we think of them as being such a minor
> variation of circles.

You can use the code I posted on the FEX recently.
arclength computes the arc length along a general
space curve in n dimensions, fitting a parametric
spline to the points, and then integrating to get
arc length. arclength also returns the length of each
individual segment of the curve.

x = linspace(0,1,6);
y = exp(2*x);
[totallength,seglength] = arclength(x,y,'spline')
totallength =
       6.4946
seglength =
      0.53128
      0.76085
       1.1129
       1.6453
       2.4443

In three dimensions, here is a helical spiral, but
with random spacing.

t = [0,sort(rand(1,20)),1]*2*pi;
x = cos(t);
y = sin(t);
z = t;

The piecewise linear arc length of the curve is
arclength(x,y,z)
ans =
       8.8244

Integrating a parametric pchip interpolant gives a
more accurate result.

arclength(x,y,z,'pchip')
ans =
       8.8653

Integrating a parametric spline gives an even more
accurate result.

arclength(x,y,z,'spline')
ans =
       8.8828

I also wrote a related function, to interpolate points
along the arc that are equally spaced in arc length.
Thus, to get 10 points along the space curve that are
equally spaced in arc length ...

interparc(10,x,y,z,'spline')
ans =
            1 3.506e-16 3.5002e-16
      0.76615 0.64257 0.69787
      0.17404 0.98396 1.396
     -0.49953 0.86626 2.0939
     -0.93936 0.3427 2.7918
     -0.93996 -0.34112 3.4897
     -0.50092 -0.86514 4.1876
      0.17256 -0.98506 4.8858
      0.76127 -0.6401 5.5844
            1 -2.6368e-16 6.2832

http://www.mathworks.com/matlabcentral/fileexchange/26848-arclength
http://www.mathworks.com/matlabcentral/fileexchange/27096-interparc

HTH,
John

Subject: arc length

From: ImageAnalyst

Date: 7 Apr, 2010 18:38:38

Message: 5 of 8

I could be wrong but I'm not sure "bo" was thinking of anything this
complicated. I wouldn't be surprised if he was simply thinking of a
simple circle and he just wrote radius instead of angle. (I mean,
would *you* be talking about exactly two radiui if you were talking
about some arbitrarily, wandering/arcing curve?) And he might know
that the arc length along a circle is the radius times the angle but
he doesn't know how to deal with radians or doesn't know how to handle
when the angle is on either side of 0 degrees or radians. Although
some have been very generous with their time for bo, personally I
wouldn't go to any effort for bo until he responds in some way. He
may have dropped off the planet or found a solution already to his
poorly described question.

Subject: arc length

From: Mark Shore

Date: 7 Apr, 2010 22:32:19

Message: 6 of 8

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <8a92961c-680d-43b3-86c4-4b1005d5c41f@z7g2000yqb.googlegroups.com>...
> I could be wrong but I'm not sure "bo" was thinking of anything this
> complicated. I wouldn't be surprised if he was simply thinking of a
> simple circle and he just wrote radius instead of angle. (I mean,
> would *you* be talking about exactly two radiui if you were talking
> about some arbitrarily, wandering/arcing curve?) And he might know
> that the arc length along a circle is the radius times the angle but
> he doesn't know how to deal with radians or doesn't know how to handle
> when the angle is on either side of 0 degrees or radians. Although
> some have been very generous with their time for bo, personally I
> wouldn't go to any effort for bo until he responds in some way. He
> may have dropped off the planet or found a solution already to his
> poorly described question.

Your suggestion prompted me to look at bo's previous posts, in one where he notes that he only started using MATLAB about mid-February. But I learned something new from Walter's post, and there's a mini-demo of John's latest FEX contribution, so thanks.

Subject: arc length

From: Roger Stafford

Date: 7 Apr, 2010 23:59:06

Message: 7 of 8

Walter Roberson <roberson@hushmail.com> wrote in message <hpi624$rn0$1@canopus.cc.umanitoba.ca>...
> bo wrote:
>
> > How to calculate arc length between 2 different radius?As I only know,
> > the arc length inside circle is r*(theta2-theta1).
>
> In addition to what Roger wrote: note that the integration that he
> suggests is correct in theory, but has the technical problem that closed
> forms for the calculation of arc length are known for only a relatively
> small number of shapes. For example there is a whole branch of calculus
> dealing with integration along ellipses, which there is no closed
> formula for, even though we think of them as being such a minor
> variation of circles.

  Yes, the arc length along the curve of an ellipse is given by an elliptic integral of the second kind incomplete, which apparently is where these integrals' name originally came from.

Roger Stafford

Subject: arc length

From: John D'Errico

Date: 8 Apr, 2010 00:53:04

Message: 8 of 8

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <hpj68a$mco$1@fred.mathworks.com>...
> Walter Roberson <roberson@hushmail.com> wrote in message <hpi624$rn0$1@canopus.cc.umanitoba.ca>...
> > bo wrote:
> >
> > > How to calculate arc length between 2 different radius?As I only know,
> > > the arc length inside circle is r*(theta2-theta1).
> >
> > In addition to what Roger wrote: note that the integration that he
> > suggests is correct in theory, but has the technical problem that closed
> > forms for the calculation of arc length are known for only a relatively
> > small number of shapes. For example there is a whole branch of calculus
> > dealing with integration along ellipses, which there is no closed
> > formula for, even though we think of them as being such a minor
> > variation of circles.
>
> Yes, the arc length along the curve of an ellipse is given by an elliptic integral of the second kind incomplete, which apparently is where these integrals' name originally came from.
>
> Roger Stafford

A neat thing is that I could compute arc lengths
for a parametric spline using an odesolver. I found
this to be a fun application of such a tool in building
those codes. It is probably why I posted those tools.

One thing I did not test is whether one of the ode
solvers might be better than another. I simply threw
ode45 at the problem. Furthermore, I have a funny
feeling that I can create a stiff problem by carefully
crafting the shape of a curve. This suggests that
ode45 might not always be the best choice there.

There are simply too many neat things to learn and
to try.

John

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us