From 7bde9516f8ce26c83fb3e5b050abf0ef4f37738d Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Tue, 14 Aug 2018 16:18:16 +0200 Subject: [PATCH] :sparkles: Added utils.beamCrossesX() --- src/utils.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utils.js b/src/utils.js index e48092a401d..77d73809359 100644 --- a/src/utils.js +++ b/src/utils.js @@ -46,6 +46,15 @@ export function linesCross(a1, a2, b1, b2) { else return false; } +/** Find where an (endless) line crosses a certain X-value */ +export function beamCrossesX(from, to, x) { + if (from.x === to.x) return false; // Vertical line + let top = new Point(x, -10); + let bottom = new Point(x, 10); + + return beamsCross(from, to, top, bottom); +} + /** Find where an (endless) line crosses a certain Y-value */ export function beamCrossesY(from, to, y) { if (from.y === to.y) return false; // Horizontal line