mirror of
https://github.com/photonstorm/phaser
synced 2024-12-18 09:03:29 +00:00
41 lines
780 B
JavaScript
41 lines
780 B
JavaScript
|
|
var LineToCircle = require('./LineToCircle');
|
|
var Contains = require('../triangle/Contains');
|
|
|
|
var TriangleToCircle = function (triangle, circle)
|
|
{
|
|
// First the cheapest ones:
|
|
|
|
if (
|
|
triangle.left > circle.right ||
|
|
triangle.right < circle.left ||
|
|
triangle.top > circle.bottom ||
|
|
triangle.bottom < circle.top)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (Contains(triangle, circle.x, circle.y))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (LineToCircle(triangle.getLineA(), circle))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (LineToCircle(triangle.getLineB(), circle))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (LineToCircle(triangle.getLineC(), circle))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
module.exports = TriangleToCircle;
|