Skip to content

Commit 1f1c492

Browse files
better rounding fix
1 parent ebb754e commit 1f1c492

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

JS/MainLoop.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function mainLoop(particlesLeft, particlesRight, translation) {
2929
c.lineWidth = 0.2;
3030
});
3131

32-
$('#tempLeft').html(Math.round(average(leftTemps)* particleMass));
32+
$('#tempLeft').html(Math.round(average(leftTemps)* particleMass * roundingAccuaracy)/roundingAccuaracy);
3333

3434
particlesRight.forEach(function (particle, i) {
3535
rightTemps.push(particle.vel.r);
@@ -44,7 +44,7 @@ function mainLoop(particlesLeft, particlesRight, translation) {
4444
c.lineWidth = 0.2;
4545
});
4646

47-
$('#tempRight').html(Math.round(average(rightTemps) * particleMass));
47+
$('#tempRight').html(Math.round(average(rightTemps) * particleMass * roundingAccuaracy)/roundingAccuaracy);
4848

4949
if(!allowCrossOver){
5050
c.beginPath()

JS/Start.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44
//user settings
55
const fps = 30;
6+
const roundingAccuaracy = 100;
67

78
//left side
89
var initTempLeft = 20;

0 commit comments

Comments
 (0)