Mercurial > repos > public > sbplib
diff +grid/Curve.m @ 99:ecf77a50d4fe feature/arclen-param
The arclength parameter function was slow because it called fzero. Now it is constructed once and for all with splines. Much better performance.
author | Martin Almquist <martin.almquist@it.uu.se> |
---|---|
date | Sun, 06 Dec 2015 15:41:42 +0100 |
parents | b30f3d8845f4 |
children | bc5db54f9efd |
line wrap: on
line diff
--- a/+grid/Curve.m Sun Dec 06 13:47:12 2015 +0100 +++ b/+grid/Curve.m Sun Dec 06 15:41:42 2015 +0100 @@ -108,8 +108,9 @@ arcVec = grid.Curve.arcLength(obj.gp,0,tvec); arcLength = grid.Curve.spline(tvec,arcVec); - % Stretch the parameter - arcPar = @(t) util.fzero_vec(@(s)arcLength(s) - t*arcLength(1),[0-10*eps,1+10*eps]); + % Stretch the parameter, construct function with splines + arcParVec = util.fzero_vec(@(s)arcLength(s) - tvec*arcLength(1),[0-10*eps,1+10*eps]); + arcPar = grid.Curve.spline(tvec,arcParVec); % New function and derivative g_new = @(t)obj.g(arcPar(t));