@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
20 lines (17 loc) • 523 B
JavaScript
import { assert } from "../../assert.js";
/**
* Returns true if two 1D lines intersect, touch is treated as intersection
* Parameters are assumed to be ordered, a1 >= a0, b1 >= b0
* @param {Number} a0
* @param {Number} a1
* @param {Number} b0
* @param {Number} b1
* @returns {boolean}
*/
export function intersects1D(a0, a1, b0, b1) {
assert.isNumber(a0, "a0");
assert.isNumber(a1, "a1");
assert.isNumber(b0, "b0");
assert.isNumber(b1, "b1");
return a1 >= b0 && b1 >= a0;
}