Lesson 13 of 18

Parametric Arc Length

Parametric Arc Length

A parametric curve is defined by two functions of a parameter tt:

x=x(t),quady=y(t),quadtin[t0,t1]x = x(t), quad y = y(t), quad t in [t_0, t_1]

The arc length is:

L=intt0t1sqrt[x(t)]2+[y(t)]2,dtL = int_{t_0}^{t_1} sqrt{[x'(t)]^2 + [y'(t)]^2} , dt

Why It Works

At parameter tt, the curve moves xdtx'dt in xx and ydty'dt in yy. The Pythagorean theorem gives length sqrtx2+y2,dtsqrt{x'^2+y'^2},dt.

Examples

Diagonal line x=t,y=tx=t, y=t on [0,1][0,1]: x=y=1x'=y'=1, so L=sqrt2approx1.4142L = sqrt{2} approx 1.4142

Line with slope x=t,y=2tx=t, y=2t on [0,1][0,1]: x=1x'=1, y=2y'=2, so L=sqrt5approx2.2361L = sqrt{5} approx 2.2361

Circle x=cos(t),y=sin(t)x=cos(t), y=sin(t) on [0,2pi][0,2pi]:

x=sin(t),y=cos(t)impliessqrtsin2t+cos2t=1x'=-sin(t), y'=cos(t) implies sqrt{sin^2 t + cos^2 t} = 1 L=int02pi1,dt=2piapprox6.2832L = int_0^{2pi} 1 , dt = 2pi approx 6.2832

Numerical Approach

for each midpoint t:
    double xp = (x_fn(t+h) - x_fn(t-h)) / (2*h);
    double yp = (y_fn(t+h) - y_fn(t-h)) / (2*h);
    sum += my_sqrt(xp*xp + yp*yp);

Your Task

Implement double param_arc_length(double (*x_fn)(double), double (*y_fn)(double), double t0, double t1, int n, double h).

TCC compiler loading...
Loading...
Click "Run" to execute your code.