Version 0.4.1 - Copyright 2014 - Jim Riecken jimr@jimr.ca
Released under the MIT License
Adapted to js-2dmath by Luis Lafuente llafuente@noboxout.com
A simple library for determining intersections of circles and polygons using the Separating Axis Theorem.
source: https://github.com/jriecken/sat-js
reference: http://physics2d.com/content/separation-axis
-
getPointInCircle (vec2: Vec2, circle: Circle): Boolean
Check if a point is inside a circle.
-
getPointInPolygon (out_response: Collision.Response, vec2: Vec2, poly: Polygon): Boolean
Check if a point is inside a convex polygon.
-
getCircleCircle (out_response: Collision.Response, a_circle: Circle, b_circle: Circle): Boolean
Check if two circles collide.
-
getPolygonCircle (out_response: Collision.Response, poly_points: Polygon, poly_edges: Polygon, poly_pos: Vec2, circle: Circle): Boolean
Check if a polygon and a circle collide.
-
getCirclePolygon (out_response: Collision.Response, circle: Circle, poly: Polygon): Boolean
Check if a circle and a polygon collide.
note: This is slightly less efficient than polygonCircle as it just runs polygonCircle and reverses everything at the end.
todo: This is slightly less efficient than polygonCircle as it just runs polygonCircle and reverses everything at the end.
-
getPolygonPolygon (out_response: Collision.Response, a_points: Polygon, a_normals: Polygon, a_pos: Vec2, b_points: Polygon, b_normals: Polygon, b_pos: Vec2): Boolean
Checks whether polygons collide.