From 9dbecd213b9d258f9050a443db75d7124f96201b Mon Sep 17 00:00:00 2001 From: coder0xff Date: Sat, 14 Mar 2015 01:26:13 -0400 Subject: [PATCH] Update ellipse.coffee Fix to pass unit tests --- app/lib/world/ellipse.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/lib/world/ellipse.coffee b/app/lib/world/ellipse.coffee index 2a45b04ba..686b44b46 100644 --- a/app/lib/world/ellipse.coffee +++ b/app/lib/world/ellipse.coffee @@ -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)