diff options
Diffstat (limited to 'src/paperflight/static/util.js')
-rw-r--r-- | src/paperflight/static/util.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/paperflight/static/util.js b/src/paperflight/static/util.js index f818809..3f14182 100644 --- a/src/paperflight/static/util.js +++ b/src/paperflight/static/util.js @@ -13,4 +13,13 @@ function isPlaneInBox(box) { || isPointInBox(plane.x + plane.width, plane.y, box) || isPointInBox(plane.x + plane.width, plane.y + plane.height, box) || isPointInBox(plane.x, plane.y + plane.height, box) +} +function isPointInCircle(x, y, circle) { + return Math.sqrt(Math.pow(x - circle.x, 2) + Math.pow(y - circle.y, 2)) < circle.radius +} +function isPlaneInCircle(circle) { + return isPointInCircle(plane.x, plane.y, circle) + || isPointInCircle(plane.x + plane.width, plane.y, circle) + || isPointInCircle(plane.x + plane.width, plane.y + plane.height, circle) + || isPointInCircle(plane.x, plane.y + plane.height, circle) }
\ No newline at end of file |