Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

triangle-circle-collision

mattdesl21MIT1.0.4

detect if a 2D triangle and circle collide

collide, collision, collided, hit, test, hittest, circle, triangle, tris, tri, pointintersect, intersection

readme

triangle-circle-collision

stable

Detects if a circle collides with or is fully inside of a triangle.

var collide = require('triangle-circle-collision')

var triangle = [[350,300], [450,450], [350, 450]]
var point = [25, 15],
    radius = 15

//returns true if collision occurs
console.log( collide(triangle, point, radius) )

You may also be interested in:

Usage

NPM

collide(triangle, circle, radius)

Returns true if the circle intersects a triangle edge or if it's fully enclosed by the triangle. Returns false if no collision occurs.

This uses barycentric coordinates to determine if the point is within the circle, and then tests the circle against each edge of the triangle.

License

MIT, see LICENSE.md for details.