├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── SAT.js ├── examples ├── dynamic_collision.html ├── examples.js └── simple_collision.html ├── package.json └── test └── test.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 0.9.0 (April 4, 2021) 4 | 5 | - Add `getAABBAsBox` methods to `Polygon` and `Circle` that returns a `Box` (`getAABB` returns a `Polygon`) - thanks [getkey](https://github.com/getkey)! 6 | 7 | ## 0.8.0 (Sept 7, 2019) 8 | 9 | - Combine consecutive duplicate points in polygons to remove zero-length edges. (Fixes #55) 10 | - Add the ability to set an offset for circles - thanks [funnisimo](https://github.com/funnisimo)! 11 | 12 | ## 0.7.1 (May 23, 2018) 13 | 14 | - Check explicitly for `undefined` `y` param when scaling vectors. (Fixes #52) 15 | 16 | ## O.7.0 (Feb 17, 2018) 17 | 18 | - Add `getCentroid` method to `Polygon` that computes the [centroid](https://en.wikipedia.org/wiki/Centroid#Centroid_of_a_polygon). (Fixes #50) 19 | - Useful for computing the center of a polygon if you want to rotate around it. 20 | 21 | ## 0.6.0 (Sept 11, 2016) 22 | 23 | - Fix "Vornoi" -> "Voronoi" everywhere. Changes are all in private code, no functional changes. (Fixes #27) 24 | - Exposed isSeparatingAxis() function - thanks [hexus](https://github.com/hexus)! 25 | - Allow pointInPolygon to work with small polygons. (Fixes #41) 26 | 27 | ## 0.5.0 (Dec 26, 2014) 28 | 29 | - **(POTENTIALLY BREAKING CHANGE)** Make `recalc` on `Polygon` more memory efficient. It no longer does any allocations. The `calcPoints`,`edges` and `normals` vector arrays are reused and only created in `setPoints` when the number of new points is different than the current ones. (Fixes #15) 30 | - `points`, `angle` and `offset` can no longer be manually changed. The `setPoints`, `setAngle`, and `setOffset` methods **must** be used. 31 | - As a result of this, the `recalc` method is no longer part of the API. 32 | - Add `getAABB` to `Polygon` and `Circle` that calculate Axis-Aligned Bounding Boxes - thanks [TuurDutoit](https://github.com/TuurDutoit)! (Fixes #17) 33 | 34 | ## 0.4.1 (Mar 23, 2014) 35 | 36 | - Fix missing `T_VECTORS.push()` - thanks [shakiba](https://github.com/shakiba)! (Fixes #8) 37 | - Add `package.json` - released as `npm` module (Fixes #11, Fixes #12) 38 | 39 | ## 0.4 (Mar 2, 2014) 40 | 41 | - Add `clone` method to `Vector` that returns a new vector with the same coordinates. 42 | - Add `angle` and `offset` to `Polygon` that are used to modify the computed collision polygon (Fixes #3, Fixes #4) 43 | - The `rotate` and `translate` methods still exist on `Polygon` but they modify the original `points` of the polygon, wheras `angle` and `offset` do not modify the original points, and are instead applied as computed values. 44 | - Add `setPoints`, `setAngle`, and `setOffset` methods to `Polygon` 45 | 46 | ## 0.3 (Feb 11, 2014) 47 | 48 | - Add `pointInCircle` and `pointInPolygon` functions for performing "hit tests" (Fixes #2) 49 | 50 | ## 0.2 (Dec 8, 2013) 51 | 52 | - Reformat comments so that they can be run through `docco` to create an annotated source file. 53 | - Fix/optimize compilation with the Closure Compiler in advanced mode (previously it was mangling some important properties) 54 | - Wrap the code in a UMD declaration so that it works: 55 | - Just inserting it as a ` 6 | 7 | 8 | 9 | 10 |
11 |Drag the shapes around. If they collide they will be moved so that they don't collide. The circle is "heavy" - it will not be moved by other items (but will move other items)
15 | 16 | 31 | 32 |Drag any of the circles and watch them react.
34 | 35 | 51 | 52 | 53 |