UNPKG

intersects

Version:

a simple collection of 2d collision/intersects functions, supporting points, circles, circle outlines (circumference), lines, axis-aligned boxes, and polygons (convex)

17 lines (16 loc) 463 B
/** * ellipse-point collision * @param {number} xe center of ellipse * @param {number} ye center of ellipse * @param {radius} rex radius-x of ellipse * @param {radius} rey radius-y of ellipse * @param {number} x1 point * @param {number} y1 point * @return {boolean} */ module.exports = function ellipsePoint(xe, ye, rex, rey, x1, y1) { var x = Math.pow(x1 - xe, 2) / (rex * rex) var y = Math.pow(y1 - ye, 2) / (rey * rey) return x + y <= 1 }