comparison +parametrization/Curve.m @ 1106:00203fcc962f

Merged in feature/dataspline (pull request #14) Feature/dataspline Approved-by: Jonatan Werpers <jonatan.werpers@it.uu.se> Approved-by: Martin Almquist <malmquist@stanford.edu>
author Martin Almquist <malmquist@stanford.edu>
date Tue, 09 Apr 2019 20:24:21 +0000
parents 7f4aae76e06a
children 60c875c18de3
comparison
equal deleted inserted replaced
1096:78d7e4e28e3e 1106:00203fcc962f
101 assert(~isempty(obj.gp),'Curve has no derivative!'); 101 assert(~isempty(obj.gp),'Curve has no derivative!');
102 102
103 % Construct arcLength function using splines 103 % Construct arcLength function using splines
104 tvec = linspace(0,1,N); 104 tvec = linspace(0,1,N);
105 arcVec = obj.arcLength(0,tvec); 105 arcVec = obj.arcLength(0,tvec);
106 tFunc = spline(arcVec,tvec); % t as a function of arcLength 106
107 % t as a function of arcLength. Monotonicity-preserving cubic splines.
108 tFunc = @(arcLen) pchip(arcVec,tvec,arcLen);
109
107 L = obj.arcLength(0,1); 110 L = obj.arcLength(0,1);
108 arcPar = @(s) tFunc(s*L); 111 arcPar = @(s) tFunc(s*L);
109 112
110 % New function and derivative 113 % New function and derivative
111 g_new = @(t)obj.g(arcPar(t)); 114 g_new = @(t)obj.g(arcPar(t));
347 end 350 end
348 351
349 end 352 end
350 end 353 end
351 354
352
353
354 function g_norm = normalize(g0) 355 function g_norm = normalize(g0)
355 g1 = g0(1,:); 356 g1 = g0(1,:);
356 g2 = g0(2,:); 357 g2 = g0(2,:);
357 normalization = sqrt(sum(g0.^2,1)); 358 normalization = sqrt(sum(g0.^2,1));
358 g_norm = [g1./normalization; g2./normalization]; 359 g_norm = [g1./normalization; g2./normalization];