From 56d153aa978255b8301c9f1ef37bafa5ac69c5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ju=CC=88rg=20Lehni?= Date: Thu, 21 Oct 2021 10:15:34 +0200 Subject: [PATCH] Add separate ANGULAR_EPSILON for arcTo() --- src/path/Path.js | 6 ++++-- src/util/Numerical.js | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/path/Path.js b/src/path/Path.js index aeaac00877..a6b22e0804 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -2575,12 +2575,14 @@ new function() { // PostScript-style drawing commands } } if (extent) { - var epsilon = /*#=*/Numerical.GEOMETRIC_EPSILON, + var epsilon = /*#=*/Numerical.ANGULAR_EPSILON, ext = abs(extent), // Calculate amount of segments required to approximate over // `extend` degrees (extend / 90), but prevent ceil() from // rounding up small imprecisions by subtracting epsilon. - count = ext >= 360 ? 4 : Math.ceil((ext - epsilon) / 90), + count = ext >= 360 + ? 4 + : Math.ceil((ext - epsilon) / 90), inc = extent / count, half = inc * Math.PI / 360, z = 4 / 3 * Math.sin(half) / (1 + Math.cos(half)), diff --git a/src/util/Numerical.js b/src/util/Numerical.js index 6b6a456da3..28355574f8 100644 --- a/src/util/Numerical.js +++ b/src/util/Numerical.js @@ -152,6 +152,11 @@ var Numerical = new function() { * as examining cross products to check for collinearity. */ TRIGONOMETRIC_EPSILON: 1e-8, + /** + * The epsilon to be used when performing angular checks in degrees, + * e.g. in `arcTo()`. + */ + ANGULAR_EPSILON: 1e-5, /** * Kappa is the value which which to scale the curve handles when * drawing a circle with bezier curves.