Compare commits
No commits in common. "ff491467e3244abe8a5a4e9ea1917cfaecdd8735" and "33aab6af5ca04ef675791539e211e744651a7830" have entirely different histories.
ff491467e3
...
33aab6af5c
2 changed files with 5 additions and 4 deletions
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
<title>Electrons on a sphere - atomic.garden</title>
|
<title>p5.js</title>
|
||||||
<script src="lib/p5.js"></script>
|
<script src="lib/p5.js"></script>
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
|
@ -104,7 +104,7 @@ aside > container > div {
|
||||||
<noscript>
|
<noscript>
|
||||||
This page requires JavaScript.
|
This page requires JavaScript.
|
||||||
<br>
|
<br>
|
||||||
Source code: <a href="https://git.atomic.garden/root/sphere-electrons">https://git.atomic.garden/root/sphere-electrons</a>
|
Source code: <a href="https://git.atomic.garden/root/sphere-charges">https://git.atomic.garden/root/sphere-charges</a>
|
||||||
</noscript>
|
</noscript>
|
||||||
<script src="thomson-problem.js"></script>
|
<script src="thomson-problem.js"></script>
|
||||||
<script src="sketch.js"></script>
|
<script src="sketch.js"></script>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function move_charges(charges) {
|
function move_charges(charges) {
|
||||||
for (let charge of charges) {
|
for (charge of charges) {
|
||||||
charge.acceleration.setMag(0);
|
charge.acceleration.setMag(0);
|
||||||
}
|
}
|
||||||
for (let i = 0; i < charges.length; i += 1) {
|
for (let i = 0; i < charges.length; i += 1) {
|
||||||
|
@ -23,7 +23,8 @@ function move_charges(charges) {
|
||||||
charges[j].acceleration.add(aj);
|
charges[j].acceleration.add(aj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let charge of charges) {
|
for (let i = 0; i < charges.length; i += 1) {
|
||||||
|
let charge = charges[i];
|
||||||
charge.velocity = charge.velocity.add(charge.acceleration);
|
charge.velocity = charge.velocity.add(charge.acceleration);
|
||||||
charge.position = charge.position.add(charge.velocity);
|
charge.position = charge.position.add(charge.velocity);
|
||||||
charge.position.normalize();
|
charge.position.normalize();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue