diff options
author | Karl Berry <karl@freefriends.org> | 2020-03-03 22:35:09 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-03-03 22:35:09 +0000 |
commit | f6bb2b5974c9dc15a4530842100d30fe1981b973 (patch) | |
tree | 62ef95efa54d91b6eafb6df99f330dc136f77f29 /Build/source/utils/asymptote/path.cc | |
parent | 24dbc0b1802756862bedad6a4088f50aad68b51b (diff) |
asy 2.63 sources
git-svn-id: svn://tug.org/texlive/trunk@54034 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/path.cc')
-rw-r--r-- | Build/source/utils/asymptote/path.cc | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/Build/source/utils/asymptote/path.cc b/Build/source/utils/asymptote/path.cc index 47461cef0d1..d9ad3e668b2 100644 --- a/Build/source/utils/asymptote/path.cc +++ b/Build/source/utils/asymptote/path.cc @@ -600,7 +600,19 @@ static double ds(double t) return sqrt(dx*dx+dy*dy); } -// Calculates arclength of a cubic using adaptive simpson integration. +// Calculates arclength of a cubic Bezier curve using adaptive Simpson +// integration. +double arcLength(const pair& z0, const pair& c0, const pair& c1, + const pair& z1) +{ + double integral; + derivative(a,b,c,z0,c0,c1,z1); + + if(!simpson(integral,ds,0.0,1.0,DBL_EPSILON,1.0)) + reportError("nesting capacity exceeded in computing arclength"); + return integral; +} + double path::cubiclength(Int i, double goal) const { const pair& z0=point(i); @@ -611,14 +623,8 @@ double path::cubiclength(Int i, double goal) const return (goal < 0 || goal >= L) ? L : -goal/L; } - const pair& c0=postcontrol(i); - const pair& c1=precontrol(i+1); - - double integral; - derivative(a,b,c,z0,c0,c1,z1); - - if(!simpson(integral,ds,0.0,1.0,DBL_EPSILON,1.0)) - reportError("nesting capacity exceeded in computing arclength"); + double integral=arcLength(z0,postcontrol(i),precontrol(i+1),z1); + L=3.0*integral; if(goal < 0 || goal >= L) return L; |