From b5f81bb54de3eb6ce13399c3c60a3861964800ff Mon Sep 17 00:00:00 2001 From: Hao Huang Date: Sun, 4 Aug 2024 15:22:06 +0800 Subject: [PATCH] optimize utils.droots --- src/utils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils.js b/src/utils.js index e4ab49c..b66f934 100644 --- a/src/utils.js +++ b/src/utils.js @@ -624,7 +624,11 @@ const utils = { c = p[2], d = a - 2 * b + c; if (d !== 0) { - const m1 = -sqrt(b * b - a * c), + const m1Pow2 = b * b - a * c + if (m1Pow2 < 0) { + return [] + } + const m1 = -sqrt(m1Pow2), m2 = -a + b, v1 = -(m1 + m2) / d, v2 = -(-m1 + m2) / d;