Skip to content

Commit

Permalink
Add separate ANGULAR_EPSILON for arcTo()
Browse files Browse the repository at this point in the history
  • Loading branch information
lehni committed Oct 21, 2021
1 parent a11d396 commit 56d153a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/path/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
5 changes: 5 additions & 0 deletions src/util/Numerical.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 56d153a

Please sign in to comment.