Compare commits
2 commits
33aab6af5c
...
ff491467e3
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ff491467e3 | ||
![]() |
f496127bf9 |
2 changed files with 4 additions and 5 deletions
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue