Skip to content

Instantly share code, notes, and snippets.

@vasturiano
vasturiano / README.md
Last active February 11, 2023 04:03
Quad Pong

A quadrilateral self-version of the Pong classic game.

Uses the d3-force simulation engine and custom forces to handle the collision and bounce between balls (d3.forceBounce) and with the paddles (d3.forceSurface).

Click-drag to control the paddles' horizontal and vertical positions. Each time a ball bounces on a paddle you get 1 point. Each time it goes off screen you lose 2 points.

Use the top-left +/- buttons to add/remove balls from the system.

@vasturiano
vasturiano / README.md
Last active December 8, 2023 14:40
3D-Force/ThreeJS stress test
@vasturiano
vasturiano / .blocks.json
Last active February 17, 2023 13:51
VR Force-Directed Graph
{"nodes":[{"id":"4062045","user":"mbostock","description":"Force-Directed Graph"},{"id":"1341021","user":"mbostock","description":"Parallel Coordinates"},{"id":"1341281","user":"jasondavies","description":"Parallel Coordinates"},{"id":"b3ff6ae1c120eea654b5","user":"d3noob","description":"Simple d3.js Graph"},{"id":"4963004","user":"calvinmetcalf","description":"Quadtree Madness Round 2"},{"id":"4962892","user":"calvinmetcalf","description":"Quadtree Madness Round 2"},{"id":"4963273","user":"calvinmetcalf","description":"Quadtree Madness Round 2"},{"id":"4967213","user":"calvinmetcalf","description":"Rtree Madness"},{"id":"4060606","user":"mbostock","description":"Choropleth"},{"id":"4686432","user":"dwtkns","description":"Faux-3d Shaded Globe"},{"id":"3757101","user":"mbostock","description":"Lambert Azimuthal Equal-Area"},{"id":"5028304","user":"d3noob","description":"Sankey diagram with horizontal and vertical node movement"},{"id":"4343214","user":"mbostock","description":"Quadtree"},{"id":"1346410","user"
@vasturiano
vasturiano / .blocks.json
Last active July 26, 2023 07:49
Multi-dimensional D3 force simulation
{"nodes":[{"id":"4062045","user":"mbostock","description":"Force-Directed Graph"},{"id":"1341021","user":"mbostock","description":"Parallel Coordinates"},{"id":"1341281","user":"jasondavies","description":"Parallel Coordinates"},{"id":"b3ff6ae1c120eea654b5","user":"d3noob","description":"Simple d3.js Graph"},{"id":"4963004","user":"calvinmetcalf","description":"Quadtree Madness Round 2"},{"id":"4962892","user":"calvinmetcalf","description":"Quadtree Madness Round 2"},{"id":"4963273","user":"calvinmetcalf","description":"Quadtree Madness Round 2"},{"id":"4967213","user":"calvinmetcalf","description":"Rtree Madness"},{"id":"4060606","user":"mbostock","description":"Choropleth"},{"id":"4686432","user":"dwtkns","description":"Faux-3d Shaded Globe"},{"id":"3757101","user":"mbostock","description":"Lambert Azimuthal Equal-Area"},{"id":"5028304","user":"d3noob","description":"Sankey diagram with horizontal and vertical node movement"},{"id":"4343214","user":"mbostock","description":"Quadtree"},{"id":"1346410","user"
@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 / 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 May 10, 2017 18:31
Particle Orbit
@vasturiano
vasturiano / .block
Last active April 20, 2017 19:05
React + D3
license: mit
@vasturiano
vasturiano / README.md
Last active January 31, 2024 10:29
3D Internet Topology

3D force-simulated version of Internet Interactive Map, showing AS relationships for approximately 3k ASes in the Internet core. ASes have a volume proportional to the size of their customer cone and are color-coded by continent. Rendered using 3d-force-graph.

@vasturiano
vasturiano / .blocks.json
Last active July 27, 2023 00:43
3D Force-Directed Graph (ThreeJS)
{"nodes":[{"id":"4062045","user":"mbostock","description":"Force-Directed Graph"},{"id":"1341021","user":"mbostock","description":"Parallel Coordinates"},{"id":"1341281","user":"jasondavies","description":"Parallel Coordinates"},{"id":"b3ff6ae1c120eea654b5","user":"d3noob","description":"Simple d3.js Graph"},{"id":"4963004","user":"calvinmetcalf","description":"Quadtree Madness Round 2"},{"id":"4962892","user":"calvinmetcalf","description":"Quadtree Madness Round 2"},{"id":"4963273","user":"calvinmetcalf","description":"Quadtree Madness Round 2"},{"id":"4967213","user":"calvinmetcalf","description":"Rtree Madness"},{"id":"4060606","user":"mbostock","description":"Choropleth"},{"id":"4686432","user":"dwtkns","description":"Faux-3d Shaded Globe"},{"id":"3757101","user":"mbostock","description":"Lambert Azimuthal Equal-Area"},{"id":"5028304","user":"d3noob","description":"Sankey diagram with horizontal and vertical node movement"},{"id":"4343214","user":"mbostock","description":"Quadtree"},{"id":"1346410","user"