-
Notifications
You must be signed in to change notification settings - Fork 0
Collision
Harsh Singh edited this page Jul 23, 2022
·
8 revisions
Following functions are exported by the collision.js
module.
Params
- x1 - center of first circle
- y1 - center of first circle
- r1 - radius of first circle
- x2 - center of second circle
- y2 - center of second circle
- r2 - radius of second circle
Bottlecap.Collision.circleInCircle(0, 0, 50, 10, 10, 50); // returns true
Bottlecap.Collision.circleInCircle(0, 0, 50, 100, 100, 50); // returns false
Params
- x1 - point's x coord
- y1 - point's y coord
- cx - center of circle
- cy - center of circle
- r - radius of circle
Bottlecap.Collision.pointInCircle(20, 20, 10, 10, 50); // returns true
Bottlecap.Collision.pointInCircle(-190, -180, 10, 10, 50); // returns false
Params
- x1 - left of rect1
- y1 - top of rect1
- w1 - width of rect1
- h1 - height of rect1
- x2 - left of rect2
- y2 - top of rect2
- w2 - width of rect2
- h2 - height of rect2
Bottlecap.Collision.rectInRect(0, 0, 100, 100, 50, 0, 100, 100); // true
Bottlecap.Collision.rectInRect(-500, 0, 100, 100, 50, 0, 100, 100); // false
Params
- x - point's x coord
- y - point's y coord
- rx - left of rect
- ry - top of rect
- rw - width of rect
- rh - height of rect
Bottlecap.Collision.pointInRect(0, 0, 100, 100, 50, 0, 100, 100); // true
Bottlecap.Collision.pointInRect(-500, 0, 100, 100, 50, 0, 100, 100); // false
Params
- cx - center of circle
- cy - center of circle
- r - radius of circle
- rx - left of rect
- ry - top of rect
- rw - width of rect
- rh - height of rect
Bottlecap.Collision.circleInRect(0, 0, 50, 0, 0, 100, 100); // returns true
Bottlecap.Collision.circleInRect(0, 0, 50, 300, 200, 100, 100); // returns false