From 43852a9dec4120df452d0b8fe8a2bf6e47b5efb3 Mon Sep 17 00:00:00 2001 From: JamesWigglesworth Date: Sat, 1 Jun 2019 16:34:38 -0700 Subject: [PATCH] Bug fix in Vector.is_equal() The tolerance argument in Vector.is_equal() now works for nested arrays. --- math/Vector.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/math/Vector.js b/math/Vector.js index 71cf926b..dd8d1164 100644 --- a/math/Vector.js +++ b/math/Vector.js @@ -2,7 +2,7 @@ //Vector and Matrix math functions //James Wigglesworth //Started: 6_18_16 -//Updated: 8_8_18 +//Updated: 6_1_19 var dde_github_issues = "https://github.com/cfry/dde/issues" @@ -715,7 +715,7 @@ class Vector{ } result = true for(var i = 0; i < array1_temp.length; i++){ - if (array1_temp[i] != array2_temp[i]){ + if (JSON.stringify(array1_temp[i]) != JSON.stringify(array2_temp[i])){ return false } } @@ -729,7 +729,8 @@ class Vector{ case "percent_difference": if(tolerance > 1){ - warning("Percent difference tolerance should be within 0 and 1.
Input of " + + warning("Percent difference tolerance should be within 0 and 1.
Input of " + tolerance + " changed to " + (tolerance/100) + ".") tolerance = tolerance/100 } @@ -2716,4 +2717,12 @@ function matrix_invert(M){ module.exports = Vector var Convert = require("./Convert.js") var {sind, cosd, tand, asind, acosd, atand, atan2d} = require("./Trig_in_Degrees.js") -var {warning} = require("../core/utils.js") \ No newline at end of file +var {warning} = require("../core/utils.js") +/* +if("dde" !== platform){ + module.exports = Vector + var Convert = require("./Convert.js") + var {sind, cosd, tand, asind, acosd, atand, atan2d} = require("./Trig_in_Degrees.js") + var {warning} = require("../core/utils.js") +} +*/