✅ Tests for utils
This commit is contained in:
parent
6b1c3fbaaf
commit
9d486fd617
5 changed files with 138 additions and 20 deletions
|
@ -47,14 +47,15 @@ export function beamsCross(a1, a2, b1, b2) {
|
|||
/** Find intersection of two line segments */
|
||||
export function linesCross(a1, a2, b1, b2) {
|
||||
let p = beamsCross(a1, a2, b1, b2);
|
||||
if (!p) return false;
|
||||
if (p) {
|
||||
let lenA = a1.dist(a2);
|
||||
let lenB = b1.dist(b2);
|
||||
let lenC = a1.dist(p) + p.dist(a2);
|
||||
let lenD = b1.dist(p) + p.dist(b2);
|
||||
if (round(lenA) == round(lenC) && round(lenB) == round(lenD)) return p;
|
||||
else return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Find where an (endless) line crosses a certain Y-value */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue