Switch to improved version of Line. getSignedDistance()

Based on the error analysis by @iconexperience outlined in #799
This commit is contained in:
Jürg Lehni 2015-10-08 22:56:05 +02:00
parent 5c70f47b6f
commit e92a71e8c7

View file

@ -182,11 +182,13 @@ var Line = Base.extend(/** @lends Line# */{
vx -= px;
vy -= py;
}
return Numerical.isZero(vx)
? vy >= 0 ? px - x : x - px
: Numerical.isZero(vy)
? vx >= 0 ? y - py : py - y
: (vx * (y - py) - vy * (x - px)) / Math.sqrt(vx * vx + vy * vy);
// Based on the error analysis by @iconexperience outlined in
// https://github.com/paperjs/paper.js/issues/799
return vx == 0
? vy >= 0 ? px - x : x - px
: vy == 0
? vx >= 0 ? y - py : py - y
: (vx * (y - py) - vy * (x - px)) / Math.sqrt(vx * vx + vy * vy);
}
}
});