2017-03-31 02:09:06 +00:00
|
|
|
var LineToCircle = require('./LineToCircle');
|
|
|
|
var Contains = require('../triangle/Contains');
|
|
|
|
|
2017-10-13 13:11:54 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @function Phaser.Geom.Intersects.TriangleToCircle
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {Phaser.Geom.Triangle} triangle - [description]
|
|
|
|
* @param {Phaser.Geom.Circle} circle - [description]
|
|
|
|
*
|
|
|
|
* @return {boolean} [description]
|
|
|
|
*/
|
2017-03-31 02:09:06 +00:00
|
|
|
var TriangleToCircle = function (triangle, circle)
|
|
|
|
{
|
2017-04-04 00:22:23 +00:00
|
|
|
// First the cheapest ones:
|
|
|
|
|
|
|
|
if (
|
|
|
|
triangle.left > circle.right ||
|
|
|
|
triangle.right < circle.left ||
|
|
|
|
triangle.top > circle.bottom ||
|
|
|
|
triangle.bottom < circle.top)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-07-18 08:26:43 +00:00
|
|
|
if (Contains(triangle, circle.x, circle.y))
|
2017-03-31 02:09:06 +00:00
|
|
|
{
|
|
|
|
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;
|