Skip to content

Commit c896bc0

Browse files
committed
Review comments
1 parent 9c267ea commit c896bc0

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/elements/element.line.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import defaults from '../core/core.defaults';
44
import Element from '../core/core.element';
55
import {_isPointInArea, _steppedLineTo, _bezierCurveTo} from '../helpers/helpers.canvas';
66
import {splineCurve, splineCurveMonotone} from '../helpers/helpers.curve';
7-
import {_angleDiff, _angleDiffCW, _normalizeAngle, _pointInLine, _steppedInterpolation, _bezierInterpolation} from '../helpers/helpers.math';
7+
import {_angleDiff, _angleDiffPD, _normalizeAngle, _pointInLine, _steppedInterpolation, _bezierInterpolation} from '../helpers/helpers.math';
88

99
const defaultColor = defaults.global.defaultColor;
1010

@@ -227,7 +227,7 @@ function useFastPath(options, params) {
227227

228228
function angleBetween(a, s, e) {
229229
return a === s || a === e ||
230-
(_angleDiffCW(a, s) > _angleDiffCW(a, e) && _angleDiffCW(s, a) < _angleDiffCW(e, a));
230+
(_angleDiffPD(a, s) > _angleDiffPD(a, e) && _angleDiffPD(s, a) < _angleDiffPD(e, a));
231231
}
232232

233233
function propertyFn(property) {

src/helpers/helpers.math.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,25 @@ export function _bezierInterpolation(p1, p2, t) {
169169
}
170170

171171
/**
172+
* Shortest distance between agnles, in either direction.
172173
* @private
173174
*/
174175
export function _angleDiff(a, b) {
175176
return (a - b + PITAU) % TAU - PI;
176177
}
177178

178179
/**
180+
* Normalize angle to be between 0 and 2*PI
179181
* @private
180182
*/
181183
export function _normalizeAngle(a) {
182-
return (a + TAU) % TAU;
184+
return (a % TAU + TAU) % TAU;
183185
}
184186

185187
/**
188+
* Angle difference in positive direction.
186189
* @private
187190
*/
188-
export function _angleDiffCW(a, b) {
189-
return (_normalizeAngle(b) - _normalizeAngle(a) + TAU) % TAU;
191+
export function _angleDiffPD(a, b) {
192+
return _normalizeAngle(_normalizeAngle(b) - _normalizeAngle(a));
190193
}

0 commit comments

Comments
 (0)