Newton's law of motion
Simulation of particles based on action and reaction
Simulation of particles according to the law of momentum P
m= mass
v= speed
P= m * v
Learn more about particle acceleration here: https://www.xtream.sk/zakony-vesmiru
If there are several particles of different sizes in space, their momentums will equalize. The heat in the fabric is equalized. Thus, larger particles will move slower and smaller particles faster.
The sample is constructed in such a way that large particles have the greatest speed at the beginning. However, very quickly after the collisions, you can see how the smaller particles accelerate from the larger ones and take some of their momentum. The speed of the particles is thus arranged according to their sizes. Thus, large particles fly slower on average than smaller particles. The number of particles is not as large as in reality, so there is also a considerable random factor, so sometimes it can happen that a particle flies outside the average of its size. However, the more particles you put into the simulation, the more stable the results would be.
Please refresh the page to better see the acceleration of small particles at the beginning.
In addition to the acceleration of particles, the attraction caused by the shielding of larger particles can also be observed in the simulations. It is not so noticeable, because there are few particles and it is only in 2 dimensions, so there is a higher probability of particles colliding than in 3D space, but you can still notice that larger particles bump into each other and try to be as close to each other as possible . Of course, the factor of chance sometimes caused them to move away, but it is more likely that the larger particles will come closer to each other. In fact, gravity is created by much smaller particles, which are much more numerous and have higher speeds, so there is not as much turbulence and the larger particles are more stable. A certain frequency of their touch then arises there. Because the more we push larger particles together, the stronger they will also repel each other. So everything is a matter of a certain frequency and force of impact. At the same time, the walls act as a shade, so flying particles often tend to hit the walls.
The simulation was programmed by Josh Bradley, edited by Ladislav Ides
https://joshbradley.me/object-collisions-with-canvas/
The simulation may be inaccurate and particles may speed up or slow down over time. This is due to the fact that everything is based on calculations that are carried out with perfect accuracy.
Gravity can be simulated in a similar way, but it is necessary to simulate many more particles to reduce the random impact factor of larger particles.
When observing the movement of particles, it looks like cellular activity. This suggests that with such a large number of combinations in infinite time, the emergence of cells and therefore life is inevitable.
HTML code for display:
<script type="text/javascript">sem vložíte zdrojový kód</script> <body onload="draw();"> <canvas id="canvas" width="600" height="600"></canvas> </body> |
Simulation source code:
//pohyb castic simulacia graviacie 600x600 update(time) {
/**
add(vector) {
subtract(vector) {
multiply(scalar) {
dotProduct(vector) {
get magnitude() {
get direction() { //ctx = document.getElementById('canvas').getContext('2d');
class Canvas {
sync(state) { clearDisplay() {
// opacity controls the trail effect set to 1 to remove
drawActors(actors) {
drawCircle(actor) {
class Ball { update(state, time, updateId) {
/**
/**
/**
if (distance <= this.radius + actor.radius) {
//check if hitting left or right of container
// check if hitting top or bottom of container
//if (this.position.y <= lowerLimit.y) {//moje
const newX = Math.max(Math.min(this.position.x + this.velocity.x, upperLimit.x), lowerLimit.x);
return new Ball({
get area() {
get sphereArea() {
// see elastic collision: https://en.wikipedia.org/wiki/Elastic_collision
// add mass to the system
const isMovingTowards = (particle1, particle2) => {
const runAnimation = animation => {
// return false from animation to stop
const random = (max = 9, min = 0) => { const colors = ['red', 'green', 'blue', 'purple', 'orange'];
const collidingBalls = ({ width = 600, height = 600, parent = document.body, count = 10 } = {}) => {
for (let i = 0; i < 2; i++) {
function draw() {
|