Update ellipse.coffee

Fix to pass unit tests
This commit is contained in:
coder0xff 2015-03-14 01:26:13 -04:00
parent 55e43c247f
commit 9dbecd213b

View file

@ -57,11 +57,12 @@ class Ellipse
if withRotation and @rotation # optionally rotate point into ellipse space
c = Math.cos(@rotation)
s = Math.sin(@rotation)
[x, y] = [x*c - y*s, y*c + x*s]
x = x / @width # scale point into ellipse space
y = y / @height
[x, y] = [x*c + y*s, y*c - x*s]
x = x / @width * 2 # scale point into ellipse space
y = y / @height * 2
x*x + y*y <= 1 #if the resulting point falls on/in the unit circle at 0, 0
intersectsLineSegment: (p1, p2) ->
[px1, py1, px2, py2] = [p1.x, p1.y, p2.x, p2.y]
m = (py1 - py2) / (px1 - px2)