mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Fix false positives in Curve#isLinear() and Segment#isLinear().
This commit is contained in:
parent
041c31a88a
commit
af355dc82c
2 changed files with 10 additions and 6 deletions
|
@ -666,9 +666,11 @@ statics: {
|
|||
// See Segment#isLinear():
|
||||
var p1x = v[0], p1y = v[1],
|
||||
p2x = v[6], p2y = v[7],
|
||||
l = new Point(p2x - p1x, p2y - p1y);
|
||||
return l.isCollinear(new Point(v[2] - p1x, v[3] - p1y))
|
||||
&& l.isCollinear(new Point(v[4] - p2x, v[5] - p2y));
|
||||
l = new Point(p2x - p1x, p2y - p1y),
|
||||
h1 = new Point(v[2] - p1x, v[3] - p1y),
|
||||
h2 = new Point(v[4] - p2x, v[5] - p2y);
|
||||
return l.isZero() ? h1.isZero() && h2.isZero()
|
||||
: l.isCollinear(h2) && l.isCollinear(h2);
|
||||
},
|
||||
|
||||
isFlatEnough: function(v, tolerance) {
|
||||
|
|
|
@ -571,9 +571,11 @@ var Segment = Base.extend(/** @lends Segment# */{
|
|||
// these methods that are implemented in both places.
|
||||
|
||||
isLinear: function(seg1, seg2) {
|
||||
var l = seg2._point.subtract(seg1._point);
|
||||
return l.isCollinear(seg1._handleOut)
|
||||
&& l.isCollinear(seg2._handleIn);
|
||||
var l = seg2._point.subtract(seg1._point),
|
||||
h1 = seg1._handleOut,
|
||||
h2 = seg2._handleIn;
|
||||
return l.isZero() ? h1.isZero() && h2.isZero()
|
||||
: l.isCollinear(h2) && l.isCollinear(h2);
|
||||
},
|
||||
|
||||
isCollinear: function(seg1, seg2, seg3, seg4) {
|
||||
|
|
Loading…
Reference in a new issue