annotate +grid/Curve.m @ 98:b30f3d8845f4 feature/arclen-param

Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
author Martin Almquist <martin.almquist@it.uu.se>
date Sun, 06 Dec 2015 13:47:12 +0100
parents 0a29a60e0b21
children ecf77a50d4fe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
1 classdef Curve
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
2 properties
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
3 g
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
4 gp
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
5 transformation
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: 86
diff changeset
6
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
7 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
8 methods
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
9 %TODO:
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
10 % Errors or FD if there is no derivative function added.
86
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
11 % -semi-done
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
12
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
13 % Concatenation of curves
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
14 % Subsections of curves
98
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
15 % Stretching of curve parameter - semi-done
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
16 % Curve to cell array of linesegments
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
17
98
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
18 % Can supply either derivative or a difference operator D1
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
19 function obj = Curve(g,gp,transformation,D1)
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
20 default_arg('gp',[]);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
21 default_arg('transformation',[]);
86
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
22 default_arg('D1',[]);
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
23 p_test = g(0);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
24 assert(all(size(p_test) == [2,1]), 'A curve parametrization must return a 2x1 vector.');
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
25
98
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
26 if(isempty(gp) && ~isempty(D1))
86
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
27 gp = grid.Curve.numerical_derivative(g,D1);
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
28 end
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
29
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
30 if ~isempty(transformation)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
31 transformation.base_g = g;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
32 transformation.base_gp = gp;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
33 [g,gp] = grid.Curve.transform_g(g,gp,transformation);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
34 end
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: 86
diff changeset
35
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
36 obj.g = g;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
37 obj.gp = gp;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
38 obj.transformation = transformation;
86
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
39
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
40 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
41
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
42 function n = normal(obj,t)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
43 deriv = obj.gp(t);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
44 normalization = sqrt(sum(deriv.^2,1));
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
45 n = [-deriv(2,:)./normalization; deriv(1,:)./normalization];
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
46 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
47
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
48
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: 86
diff changeset
49 % Plots a curve g(t) for 0<t<1, using n points. Returns a handle h to the plotted curve.
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
50 % h = plot_curve(g,n)
98
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
51 function h = plot(obj,n)
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
52 default_arg('n',100);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
53
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
54 t = linspace(0,1,n);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
55 p = obj.g(t);
98
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
56 h = line(p(1,:),p(2,:));
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: 86
diff changeset
57 end
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: 86
diff changeset
58
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: 86
diff changeset
59 % Plots the derivative gp(t) for 0<t<1, using n points. Returns a handle h to the plotted 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: 86
diff changeset
60 % h = plot_curve(gp,n)
98
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
61 function h = plot_derivative(obj,n)
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: 86
diff changeset
62 default_arg('n',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: 86
diff changeset
63
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: 86
diff changeset
64 t = linspace(0,1,n);
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: 86
diff changeset
65 p = obj.gp(t);
98
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
66 h = line(p(1,:),p(2,:));
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
67 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
68
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
69 function h= plot_normals(obj,l,n,m)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
70 default_arg('l',0.1);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
71 default_arg('n',10);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
72 default_arg('m',100);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
73 t_n = linspace(0,1,n);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
74
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
75 normals = obj.normal(t_n)*l;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
76
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
77 n0 = obj.g(t_n);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
78 n1 = n0 + normals;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
79
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
80 h = line([n0(1,:); n1(1,:)],[n0(2,:); n1(2,:)]);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
81 set(h,'Color',Color.red);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
82 obj.plot(m);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
83 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
84
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
85 function h= show(obj,name)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
86 p = obj.g(1/2);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
87 n = obj.normal(1/2);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
88 p = p + n*0.1;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
89
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
90 % Add arrow
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
91
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
92 h = text(p(1),p(2),name);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
93 h.HorizontalAlignment = 'center';
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
94 h.VerticalAlignment = 'middle';
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
95
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
96 obj.plot();
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
97 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
98 % Shows curve with name and arrow for direction.
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
99
86
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
100
98
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
101 % Arc length parameterization.
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
102 function curve = arcLengthStretch(obj,N)
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
103 default_arg('N',100);
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
104 assert(~isempty(obj.gp),'This curve does not yet have a derivative added.')
86
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
105
98
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
106 % Construct arcLength function using splines
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
107 tvec = linspace(0,1,N);
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
108 arcVec = grid.Curve.arcLength(obj.gp,0,tvec);
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
109 arcLength = grid.Curve.spline(tvec,arcVec);
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
110
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
111 % Stretch the parameter
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
112 arcPar = @(t) util.fzero_vec(@(s)arcLength(s) - t*arcLength(1),[0-10*eps,1+10*eps]);
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
113
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
114 % New function and derivative
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
115 g_new = @(t)obj.g(arcPar(t));
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
116 gp_old = obj.gp;
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
117 gp_new = @(t) normalize(gp_old(arcPar(t)));
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
118
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
119 curve = grid.Curve(g_new,gp_new);
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
120
86
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
121 end
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
122
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
123 % how to make it work for methods without returns
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
124 function p = subsref(obj,S)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
125 %Should i add error checking here?
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
126 %Maybe if you want performance you fetch obj.g and then use that
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
127 switch S(1).type
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
128 case '()'
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
129 p = obj.g(S.subs{1});
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
130 % case '.'
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
131
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
132 % p = obj.(S.subs);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
133 otherwise
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
134 p = builtin('subsref',obj,S);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
135 % error()
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
136 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
137 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
138
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
139
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
140 %% TRANSFORMATION OF A CURVE
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
141 function D = reverse(C)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
142 % g = C.g;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
143 % gp = C.gp;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
144 % D = grid.Curve(@(t)g(1-t),@(t)-gp(1-t));
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
145 D = C.transform([],[],-1);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
146 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
147
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
148 function D = transform(C,A,b,flip)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
149 default_arg('A',[1 0; 0 1]);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
150 default_arg('b',[0; 0]);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
151 default_arg('flip',1);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
152 if isempty(C.transformation)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
153 g = C.g;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
154 gp = C.gp;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
155 transformation.A = A;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
156 transformation.b = b;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
157 transformation.flip = flip;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
158 else
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
159 g = C.transformation.base_g;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
160 gp = C.transformation.base_gp;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
161 A_old = C.transformation.A;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
162 b_old = C.transformation.b;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
163 flip_old = C.transformation.flip;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
164
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
165 transformation.A = A*A_old;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
166 transformation.b = A*b_old + b;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
167 transformation.flip = flip*flip_old;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
168 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
169
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
170 D = grid.Curve(g,gp,transformation);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
171
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
172 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
173
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
174 function D = translate(C,a)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
175 g = C.g;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
176 gp = C.gp;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
177
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
178 % function v = g_fun(t)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
179 % x = g(t);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
180 % v(1,:) = x(1,:)+a(1);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
181 % v(2,:) = x(2,:)+a(2);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
182 % end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
183
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
184 % D = grid.Curve(@g_fun,gp);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
185
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
186 D = C.transform([],a);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
187 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
188
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
189 function D = mirror(C, a, b)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
190 assert_size(a,[2,1]);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
191 assert_size(b,[2,1]);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
192
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
193 g = C.g;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
194 gp = C.gp;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
195
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
196 l = b-a;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
197 lx = l(1);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
198 ly = l(2);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
199
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
200
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
201 % fprintf('Singular?\n')
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
202
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
203 A = [lx^2-ly^2 2*lx*ly; 2*lx*ly ly^2-lx^2]/(l'*l);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
204
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
205 % function v = g_fun(t)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
206 % % v = a + A*(g(t)-a)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
207 % x = g(t);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
208
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
209 % ax1 = x(1,:)-a(1);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
210 % ax2 = x(2,:)-a(2);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
211 % v(1,:) = a(1)+A(1,:)*[ax1;ax2];
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
212 % v(2,:) = a(2)+A(2,:)*[ax1;ax2];
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
213 % end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
214
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
215 % function v = gp_fun(t)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
216 % v = A*gp(t);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
217 % end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
218
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
219 % D = grid.Curve(@g_fun,@gp_fun);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
220
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
221 % g = A(g-a)+a = Ag - Aa + a;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
222 b = - A*a + a;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
223 D = C.transform(A,b);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
224
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
225 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
226
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
227 function D = rotate(C,a,rad)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
228 assert_size(a, [2,1]);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
229 assert_size(rad, [1,1]);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
230 g = C.g;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
231 gp = C.gp;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
232
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
233
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
234 A = [cos(rad) -sin(rad); sin(rad) cos(rad)];
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
235
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
236 % function v = g_fun(t)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
237 % % v = a + A*(g(t)-a)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
238 % x = g(t);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
239
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
240 % ax1 = x(1,:)-a(1);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
241 % ax2 = x(2,:)-a(2);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
242 % v(1,:) = a(1)+A(1,:)*[ax1;ax2];
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
243 % v(2,:) = a(2)+A(2,:)*[ax1;ax2];
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
244 % end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
245
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
246 % function v = gp_fun(t)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
247 % v = A*gp(t);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
248 % end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
249
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
250 % D = grid.Curve(@g_fun,@gp_fun);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
251
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
252
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
253 % g = A(g-a)+a = Ag - Aa + a;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
254 b = - A*a + a;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
255 D = C.transform(A,b);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
256 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
257 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
258
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
259 methods (Static)
86
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
260
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: 86
diff changeset
261 % Length of arc from parameter t0 to t1 (which may be vectors).
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: 86
diff changeset
262 % Computed using derivative.
98
b30f3d8845f4 Removed arclength property. Constructor compatible again. Translation and rotation are fast now, but ti is slow.
Martin Almquist <martin.almquist@it.uu.se>
parents: 87
diff changeset
263 function L = arcLength(deriv,t0,t1)
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: 86
diff changeset
264 speed = @(t) sp(deriv(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: 86
diff changeset
265
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: 86
diff changeset
266 function s = sp(deriv)
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: 86
diff changeset
267 s = sqrt(sum(deriv.^2,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: 86
diff changeset
268 end
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: 86
diff changeset
269 L = util.integral_vec(speed,t0,t1);
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: 86
diff changeset
270 end
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: 86
diff changeset
271
86
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
272 function gp_out = numerical_derivative(g,D1)
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
273 m = length(D1); L = 1; % Assume curve parameter from 0 to 1.
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
274 t = linspace(0,L,m);
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
275 g = g(t)';
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
276 gp = (D1*g)';
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: 86
diff changeset
277
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: 86
diff changeset
278 gp1_fun = grid.Curve.spline(t,gp(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: 86
diff changeset
279 gp2_fun = grid.Curve.spline(t,gp(2,:));
86
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
280 gp_out = @(t) [gp1_fun(t);gp2_fun(t)];
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
281
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
282 end
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
283
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: 86
diff changeset
284 % Returns a function handle to the spline.
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: 86
diff changeset
285 function f = spline(tval,fval,spline_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: 86
diff changeset
286 default_arg('spline_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: 86
diff changeset
287 [m,~] = size(tval);
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: 86
diff changeset
288 assert(m==1,'Need row vectors.');
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: 86
diff changeset
289
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: 86
diff changeset
290 % make vectors longer to be safe slightly beyond edges.
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: 86
diff changeset
291 dt0 = tval(2)-tval(1); dt1 = tval(end)-tval(end-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: 86
diff changeset
292 df0 = fval(2)-fval(1); df1 = fval(end)-fval(end-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: 86
diff changeset
293 tval = [tval(1)-dt0, tval, tval(end)+dt1];
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: 86
diff changeset
294 fval = [fval(1)-df0, fval, fval(end)+df1];
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: 86
diff changeset
295
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: 86
diff changeset
296 f_spline = spapi( optknt(tval,spline_order), tval, fval );
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: 86
diff changeset
297 f = @(t) fnval(f_spline,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: 86
diff changeset
298 end
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: 86
diff changeset
299
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
300 function obj = line(p1, p2)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
301
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
302 function v = g_fun(t)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
303 v(1,:) = p1(1) + t.*(p2(1)-p1(1));
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
304 v(2,:) = p1(2) + t.*(p2(2)-p1(2));
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
305 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
306 g = @g_fun;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
307
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
308 obj = grid.Curve(g);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
309 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
310
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
311 function obj = circle(c,r,phi)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
312 default_arg('phi',[0; 2*pi])
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
313 default_arg('c',[0; 0])
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
314 default_arg('r',1)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
315
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
316 function v = g_fun(t)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
317 w = phi(1)+t*(phi(2)-phi(1));
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
318 v(1,:) = c(1) + r*cos(w);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
319 v(2,:) = c(2) + r*sin(w);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
320 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
321
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
322 function v = g_fun_deriv(t)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
323 w = phi(1)+t*(phi(2)-phi(1));
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
324 v(1,:) = -(phi(2)-phi(1))*r*sin(w);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
325 v(2,:) = (phi(2)-phi(1))*r*cos(w);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
326 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
327
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
328 obj = grid.Curve(@g_fun,@g_fun_deriv);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
329 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
330
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
331 function obj = bezier(p0, p1, p2, p3)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
332 function v = g_fun(t)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
333 v(1,:) = (1-t).^3*p0(1) + 3*(1-t).^2.*t*p1(1) + 3*(1-t).*t.^2*p2(1) + t.^3*p3(1);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
334 v(2,:) = (1-t).^3*p0(2) + 3*(1-t).^2.*t*p1(2) + 3*(1-t).*t.^2*p2(2) + t.^3*p3(2);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
335 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
336
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
337 function v = g_fun_deriv(t)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
338 v(1,:) = 3*(1-t).^2*(p1(1)-p0(1)) + 6*(1-t).*t*(p2(1)-p1(1)) + 3*t.^2*(p3(1)-p2(1));
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
339 v(2,:) = 3*(1-t).^2*(p1(2)-p0(2)) + 6*(1-t).*t*(p2(2)-p1(2)) + 3*t.^2*(p3(2)-p2(2));
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
340 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
341
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
342 obj = grid.Curve(@g_fun,@g_fun_deriv);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
343 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
344
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
345
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
346 function [g_out,gp_out] = transform_g(g,gp,tr)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
347 A = tr.A;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
348 b = tr.b;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
349 flip = tr.flip;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
350
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
351 function v = g_fun_noflip(t)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
352 % v = A*g + b
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
353 x = g(t);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
354
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
355 v(1,:) = A(1,:)*x+b(1);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
356 v(2,:) = A(2,:)*x+b(2);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
357 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
358
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
359 function v = g_fun_flip(t)
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
360 % v = A*g + b
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
361 x = g(1-t);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
362
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
363 v(1,:) = A(1,:)*x+b(1);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
364 v(2,:) = A(2,:)*x+b(2);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
365 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
366
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
367
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
368 switch flip
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
369 case 1
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
370 g_out = @g_fun_noflip;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
371 gp_out = @(t)A*gp(t);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
372 case -1
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
373 g_out = @g_fun_flip;
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
374 gp_out = @(t)-A*gp(1-t);
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
375 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
376 end
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
377
86
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
378 end
0
48b6fb693025 Initial commit.
Jonatan Werpers <jonatan@werpers.com>
parents:
diff changeset
379 end
86
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
380
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
381 function g_norm = normalize(g0)
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
382 g1 = g0(1,:); g2 = g0(2,:);
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
383 normalization = sqrt(sum(g0.^2,1));
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
384 g_norm = [g1./normalization; g2./normalization];
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
385 end
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
386
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
387
3c39dd714fb6 In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
Martin Almquist <martin.almquist@it.uu.se>
parents: 0
diff changeset
388