annotate testArcLength.m @ 90:55e40b36373d

Closing this head
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 30 Nov 2015 12:26:11 +0100
parents 0a29a60e0b21
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
87
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
1 m = 201; L = 1; order = 4;
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
2 close all;
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
3 tic
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
4
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
5 g1 = @(t) 2*pi*t.*sin(2*pi*t);
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
6 g2 = @(t) 2*pi*t.*cos(2*pi*t);
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
7 g = @(t) [g1(t);g2(t)];
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
8
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
9 t = linspace(0,L,m)'; dt = L/(m-1);
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
10 ops = sbp.Ordinary(m,dt,order);
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
11 D = ops.derivatives.D1;
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
12
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
13 C = grid.Curve(g,[],[],D);
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
14
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
15 % Function
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
16 figure;
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
17 C.plot([],'bo');
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
18 hold on
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
19 plot(g1(t),g2(t),'r-');
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
20 drawnow
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
21
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
22 % Derivative
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
23 figure
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
24 C.plot_derivative([],'bo');
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
25 hold on;
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
26 plot(2*pi*sin(2*pi*t) + (2*pi)^2*t.*cos(2*pi*t),...
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
27 2*pi*cos(2*pi*t) - (2*pi)^2*t.*sin(2*pi*t),'r-')
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
28 drawnow
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
29
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
30 % Arc length
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
31 L = C.arc_length_fun(t);
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
32 figure;
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
33 plot(t,L)
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
34 drawnow
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
35
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
36 % Stretch curve
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
37 C2 = C.stretch_parameter();
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
38 z = linspace(0,1,m);
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
39 gnew = C2.g(z);
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
40 gpnew = C2.gp(z);
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
41
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
42 % Compare stretched and unstretched curves.
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
43 figure
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
44 plot(g1(t),g2(t),'b*',gnew(1,:),gnew(2,:),'ro');
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
45
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
46 % Compare stretched and unstretched derivatives.
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
47 figure
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
48 theta = linspace(0,2*pi,100);
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
49 plot(cos(theta),sin(theta),'-b',gpnew(1,:),gpnew(2,:),'rx');
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
50
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
51 toc
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
52
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
53
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
54
0a29a60e0b21 In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
Martin Almquist <martin.almquist@it.uu.se>
parents:
diff changeset
55