Reverse sign of Line.getSignedDistance()

Closes #789
This commit is contained in:
Jürg Lehni 2015-10-21 09:35:40 +02:00
parent 7c37a4a4d2
commit 0cb792de93

View file

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