Mercurial > repos > public > sbplib
comparison +parametrization/Curve.m @ 1126:465fc81e12e8 feature/poroelastic
Copy-paste improved Curve class from feature/laplace_curvilinear_test
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Mon, 13 May 2019 10:18:55 -0700 |
parents | 0776fa4754ff |
children | 60c875c18de3 |
comparison
equal
deleted
inserted
replaced
1125:0eef5c8ccb88 | 1126:465fc81e12e8 |
---|---|
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]; |