Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
positions.forEach((u, j) => { // u
if (i === j) return;
// if (j === focusIndex) return;
// the euclidean distance between v and u
const edis = Util.getEDistance(v, u);
const reciEdis = edis === 0 ? 0 : 1 / edis;
const idealDis = D[j][i];
// same for x and y
denominator += W[i][j];
// x
xMolecule += W[i][j] * (u[0] + idealDis * (v[0] - u[0]) * reciEdis);
// y
yMolecule += W[i][j] * (u[1] + idealDis * (v[1] - u[1]) * reciEdis);
});
const reciR = radii[i] === 0 ? 0 : 1 / radii[i];
positions.forEach((v, i) => { // v
const originDis = Util.getEDistance(v, [ 0, 0 ]);
const reciODis = originDis === 0 ? 0 : 1 / originDis;
if (i === focusIndex) return;
let xMolecule = 0;
let yMolecule = 0;
let denominator = 0;
positions.forEach((u, j) => { // u
if (i === j) return;
// if (j === focusIndex) return;
// the euclidean distance between v and u
const edis = Util.getEDistance(v, u);
const reciEdis = edis === 0 ? 0 : 1 / edis;
const idealDis = D[j][i];
// same for x and y
denominator += W[i][j];
// x
xMolecule += W[i][j] * (u[0] + idealDis * (v[0] - u[0]) * reciEdis);