Improve Line.getSignedDistance()

Improved code is shorter, faster, and should product results with higher precision.
This commit is contained in:
Jan 2015-01-05 15:16:45 +01:00
parent 1803cd216a
commit 60ddc68e56

View file

@ -169,8 +169,7 @@ var Line = Base.extend(/** @lends Line# */{
? vy >= 0 ? px - x : x - px
: Numerical.isZero(vy)
? vx >= 0 ? y - py : py - y
: -(vy * x - vx * y - px * (py + vy) + py * (px + vx)) /
Math.sqrt(vx * vx + vy * vy);
: (vx * (y - py) - vy * (x - px)) / Math.sqrt(vx * vx + vy * vy);
}
}
});