1
0
Fork 0

Update utils.mjs

Fix #5697
This commit is contained in:
Wouter van Wageningen 2023-12-24 15:39:33 -08:00 committed by GitHub
parent 75a643d076
commit dfe98c19cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -167,7 +167,7 @@ export function circlesIntersect(c1, r1, c2, r2, sort = 'x') {
let dist = c1.dist(c2) let dist = c1.dist(c2)
// Check for edge cases // Check for edge cases
if (dist > parseFloat(r1) + parseFloat(r2)) return false // Circles do not intersect if (dist > parseFloat(r1) + parseFloat(r2)) return false // Circles do not intersect
if (dist < parseFloat(r2) - parseFloat(r1)) return false // One circle is contained in the other if (dist < Math.abs(parseFloat(r2) - parseFloat(r1))) return false // One circle is contained in the other
if (dist === 0 && r1 === r2) return false // Two circles are identical if (dist === 0 && r1 === r2) return false // Two circles are identical
let chorddistance = (Math.pow(r1, 2) - Math.pow(r2, 2) + Math.pow(dist, 2)) / (2 * dist) let chorddistance = (Math.pow(r1, 2) - Math.pow(r2, 2) + Math.pow(dist, 2)) / (2 * dist)
let halfchordlength = Math.sqrt(Math.pow(r1, 2) - Math.pow(chorddistance, 2)) let halfchordlength = Math.sqrt(Math.pow(r1, 2) - Math.pow(chorddistance, 2))