Skip to content

Commit 288c2af

Browse files
Particle Mass
1 parent a64a461 commit 288c2af

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

JS/MainLoop.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function mainLoop(particlesLeft, particlesRight, translation) {
3030
}
3131
});
3232

33-
$('#tempLeft').html(Math.round(average(leftTemps)));
33+
$('#tempLeft').html(Math.round(average(leftTemps)* particleMass));
3434

3535
particlesRight.forEach(function (particle, i) {
3636
rightTemps.push(particle.vel.r);
@@ -49,7 +49,7 @@ function mainLoop(particlesLeft, particlesRight, translation) {
4949
}
5050
});
5151

52-
$('#tempRight').html(Math.round(average(rightTemps)));
52+
$('#tempRight').html(Math.round(average(rightTemps) * particleMass));
5353

5454
if(!allowCrossOver){
5555
c.beginPath()

JS/Start.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ const fps = 30;
33

44
//left side
55
var initTempLeft = 20;
6-
var particleMassLeft = 1;
76
var numberOfParticlesLeft = 100;
87

98
//right side
109
var initTempRight = 10;
11-
var particleMassRight = 1;
1210
var numberOfParticlesRight = 200;
1311

1412
/*
@@ -25,6 +23,7 @@ var particleRadius = 0.5;
2523
var canvasRatio = 2.1;
2624
var isFriction = false;
2725
var allowCrossOver = false
26+
var particleMass = 5;
2827

2928
//global vars
3029
var ctx;
@@ -58,7 +57,7 @@ function init(c) {
5857
initPoint.x += 50;
5958
initPoint.y += 50;
6059

61-
makeParticle(initPoint, particleRadius, particleMassLeft, initForce, particlesLeft);
60+
makeParticle(initPoint, particleRadius, particleMass, initForce, particlesLeft);
6261
}
6362

6463
for (let i = 0; i < numberOfParticlesRight; i++) {
@@ -69,7 +68,7 @@ function init(c) {
6968
initPoint.x += 160;
7069
initPoint.y += 50;
7170

72-
makeParticle(initPoint, particleRadius, particleMassRight, initForce, particlesRight);
71+
makeParticle(initPoint, particleRadius, particleMass, initForce, particlesRight);
7372
}
7473

7574
//initArrowKeys();

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<span class='setting' type='range' var='initTempRight' max='30' min='1'></span><br/>
4040
<span class='setting' type='range' var='numberOfParticlesLeft' max='200' min='50'></span><br/>
4141
<span class='setting' type='range' var='numberOfParticlesRight' max='200' min='50'></span><br/>
42+
<span class='setting' type='range' var='particleMass' max='10' min='1'></span><br/>
4243
<button onclick="resetLoop()">Reset</button>
4344
</div>
4445
</body>

0 commit comments

Comments
 (0)