Compare commits

...

2 commits

Author SHA1 Message Date
root
ff491467e3 rename to sphere-electrons 2025-04-26 13:16:45 +00:00
root
f496127bf9 mini changes 2025-04-26 13:16:37 +00:00
2 changed files with 4 additions and 5 deletions

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>p5.js</title>
<title>Electrons on a sphere - atomic.garden</title>
<script src="lib/p5.js"></script>
<style>
:root {
@ -104,7 +104,7 @@ aside > container > div {
<noscript>
This page requires JavaScript.
<br>
Source code: <a href="https://git.atomic.garden/root/sphere-charges">https://git.atomic.garden/root/sphere-charges</a>
Source code: <a href="https://git.atomic.garden/root/sphere-electrons">https://git.atomic.garden/root/sphere-electrons</a>
</noscript>
<script src="thomson-problem.js"></script>
<script src="sketch.js"></script>

View file

@ -1,5 +1,5 @@
function move_charges(charges) {
for (charge of charges) {
for (let charge of charges) {
charge.acceleration.setMag(0);
}
for (let i = 0; i < charges.length; i += 1) {
@ -23,8 +23,7 @@ function move_charges(charges) {
charges[j].acceleration.add(aj);
}
}
for (let i = 0; i < charges.length; i += 1) {
let charge = charges[i];
for (let charge of charges) {
charge.velocity = charge.velocity.add(charge.acceleration);
charge.position = charge.position.add(charge.velocity);
charge.position.normalize();