Skip to content

Instantly share code, notes, and snippets.

@vasturiano
vasturiano / README.md
Last active October 22, 2017 04:11
Orbital Trajectory

A simulation of orbital trajectories using the d3-force simulation engine with the gravity-like d3-force-magnetic attraction force.

The initial tangential velocity of the blue orbiting body can be set relative to its orbital speed, calculated as √(GM/d). A factor of 1x (default) results in a perfectly circular orbit. Approaching the factor of √2x reaches the body's escape velocity, causing the body to drift away from the central object's gravity pull in an hyperbolic trajectory. Factors below 1 will cause a quicker fall of the blue body towards the attracting center, yielding elliptic orbits with increasing eccentricity.

The length of the pre-estimated trajectory can be manipulated by changing the number of samples (represented as dots).

See also [Force-simulated So

@vasturiano
vasturiano / README.md
Last active October 22, 2017 04:13
Pendulum

Ok, I'm confused. Why isn't energy conserved and does the pendulum eventually stop?

@vasturiano
vasturiano / README.md
Last active October 22, 2017 04:13
ForceMagnetic based Hierarchical Orbits

Simulation of multiple particles orbitting around each other in a hierarchical system (e.g. sun > planet > moon).

Uses D3's force plugin forceMagnetic to connect particles to their moving gravitational centers via magnetic/electrostatic links. These magnetic attraction forces simulate the mechanics of gravity. Each link holds its own gravitational constant to exaggerate the amplitude and velocity of the orbits relative to each other, which would be otherwise impossible in a system with a single constant.

Compare with the forceLink version.

@vasturiano
vasturiano / README.md
Last active October 22, 2017 04:14
Accretion

Simulation of accretion of particles attracted by electrostatic or gravitational forces, analogous to the interaction within dust clouds found in the early stages of star formation.

Uses D3's force plugin forceMagnetic to simulate the attraction/repulsion of objects of varying mass in an inverse-square relationship with distance. Further, particles are prevented from overlapping by applying a non-elastic collision force using forceBounce.

Using the slider controls you can add/remove particles to the system, and regulate the ratio of attractive (green attracts all other) vs repellent (red repels all other).

@vasturiano
vasturiano / README.md
Last active October 22, 2017 04:15
Collision Forces Comparison
@vasturiano
vasturiano / README.md
Last active October 22, 2017 04:20
Force-simulated Solar System

Don't see anything?... Exactly! Increase the Size distortion slider to reveal the planetary bodies.

This shows a force-simulated version of the solar system. The orbital trajectories are derived purely from the configuration of distances and masses of all the bodies. It is rendered true-to-scale, which shows how vast the empty space really is in between the bodies.

The simulation is ran using the d3-force simulation engine with the gravity-like d3-force-magnetic (inverse square law) attraction force. Each body is given an initial tangential velocity, equal to its orbital speed around the central sun, calculated as √(GM/d). See also force-simulated orbit trajectories.

Use the Lock on radio buttons to select the central pivoting body. The Size distortion slider lets you exaggerate the size of the bodies l

@vasturiano
vasturiano / .block
Last active November 16, 2017 06:14 — forked from mbostock/.block
Geo Zoom & Pan using Versors
license: gpl-3.0
height: 600
border: no
@vasturiano
vasturiano / .block
Last active January 6, 2018 09:04
Musical Hexagons
license: mit
height: 800
@vasturiano
vasturiano / README.md
Last active January 30, 2018 22:22
ForceLink based Hierarchical Orbits

Attempt at simulation of multiple particles orbitting around each other in a hierarchical system (e.g. sun > planet > moon).

Uses D3 force-directed physics engine's forceLink to connect particles to their moving gravitational centers via fixed position anchor nodes.

The system fails to reach equilibrium due to the "spring" nature of forceLink, in which contrary to gravitational forces the intensity decreases with proximity, causing bodies to inevitably fall onto their attraction center. The forceMagnetic force is a better fit for modelling this type of motion.

Compare with the forceMagnetic version.

@vasturiano
vasturiano / README.md
Last active March 10, 2018 10:37
Binary Star System

A simulation of orbital trajectories using the d3-force simulation engine with the gravity-like d3-force-magnetic attraction force.

By default the layout represents a binary system. All the stars (red nodes) have the same mass and their attraction influence on the satellite (blue node) is proportional to the inverse-square of the distance. The stars are statically positioned and remain unaffected by either the satellite or other stars. Stars can be added and removed by double-clicking on canvas/nodes. All nodes can also be repositioned by dragging.

The initial velocity (and direction) of the satellite can be changed using the controls on the top-right. The length of the pre-estimated trajectory can be manipulated by changing the number of samples (represented as dots).

See also Single Orbital Trajectory.