summaryrefslogtreecommitdiff
path: root/graphics/asymptote/path.cc
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-03-04 03:02:32 +0000
committerNorbert Preining <norbert@preining.info>2020-03-04 03:02:32 +0000
commit19d25b8009801aa98ea2f46b45c37c257f990491 (patch)
treec0da70fbab26feff40e87df289ae797917df8419 /graphics/asymptote/path.cc
parentb78f5a6705512314d6fe42fd5144c5f8e5d484ce (diff)
CTAN sync 202003040302
Diffstat (limited to 'graphics/asymptote/path.cc')
-rw-r--r--graphics/asymptote/path.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/graphics/asymptote/path.cc b/graphics/asymptote/path.cc
index 47461cef0d..d9ad3e668b 100644
--- a/graphics/asymptote/path.cc
+++ b/graphics/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;