mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Update ellipse.coffee
Fix to pass unit tests
This commit is contained in:
parent
55e43c247f
commit
9dbecd213b
1 changed files with 4 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue