A collision detection library for 2D geometry in p5.js
fixes issue with collidePolyPoly() detecting only when p2 is inside p1, but not when p1 is inside p2. It now works both ways thanks to @tektsu !
The CDN's required a version number bump to properly sync so this will bring the releases up to the same number.
thank you to @wisehackermonkey for all of the work to add vector functions to the library!
As of June 2020, this library now supports vector version of all functions. Simply use the function names below with Vector added onto the function name to utilize the vector version of the function. The function's arguments take in vectors instead of x/y values. Each of the examples below now has a commented example to demonstrate vector usage. We will be updating the documentation and examples in the future to make this distinction more clear. This in no way affects the original functionality of the library.
//Use vectors as input
let p1 = createVector(100,100);
let mouse = createVector(mouseX,mouseY);
hit = collidePointPointVector(p1,mouse,10)
Thanks to @fidoaf for adding collidePointEllipse() !
I've added an auto generated min file. This is untested, if there are issues please report and divert to the un-minified version.
Adds collidePointArc(), thank you to @davidgranstrom && @ognjenvucko
Support for instantiated sketches & addition of minified version. thank you @conradoqg
fixed point/point
Initial alpha release of this library as p5.collide2D. Please report any issues to the issues tab.
2D functions only