Hylograph.Forces.ThreeD.Tick
- Package
- purescript-hylograph-forces
- Repository
- afcondon/purescript-hylograph-forces
The parts of a tick that are not forces, in three dimensions: moving the
nodes, and d3-force-3d's initializeNodes. Cooling has no dimension and
is Hylograph.Forces.Tick.cool.
Ported from d3-force-3d 3.0.6, simulation.js (MIT, Copyright 2017
Vasco Asturiano; itself from d3-force, ISC, Mike Bostock); see LICENSE.
#initializeNodes Source
initializeNodes :: forall row. Array (Node (Pinnable row)) -> Effect Unitd3-force-3d's initializeNodes at three dimensions: give every node its
index; put a pinned coordinate on its pin; give a node with no position
a place on d3-force-3d's spherical spiral; and stop a node with no
velocity.
node.index = i;
if (node.fx != null) node.x = node.fx;
if (node.fy != null) node.y = node.fy;
if (node.fz != null) node.z = node.fz;
if (isNaN(node.x) || isNaN(node.y) || isNaN(node.z)) {
var radius = initialRadius * Math.cbrt(0.5 + i),
rollAngle = i * initialAngleRoll,
yawAngle = i * initialAngleYaw;
node.x = radius * Math.sin(rollAngle) * Math.cos(yawAngle);
node.y = radius * Math.cos(rollAngle);
node.z = radius * Math.sin(rollAngle) * Math.sin(yawAngle);
}
if (isNaN(node.vx) || isNaN(node.vy) || isNaN(node.vz)) node.vx = node.vy = node.vz = 0;
A node with no position is placed whole: a node pinned in x alone, and
nowhere yet, loses its pin's x to the spiral (and gets it back at the
first tick), as in d3-force-3d. A field that is missing reads as NaN.
#initialAngleRoll Source
initialAngleRoll :: Numberd3-force-3d's initialAngleRoll, the golden angle: a value of its own,
for the reason given at Hylograph.Forces.Tick.initializeNodes (the
optimising backend would regroup i * (pi * k)).
#initialAngleYaw Source
initialAngleYaw :: Numberd3-force-3d's initialAngleYaw, Math.PI * 20 / (9 + Math.sqrt(221)).
- Modules
- Hylograph.
Forces - Hylograph.
Forces. Center - Hylograph.
Forces. Cohesion - Hylograph.
Forces. Collide - Hylograph.
Forces. Contain - Hylograph.
Forces. Directional - Hylograph.
Forces. Group - Hylograph.
Forces. Link - Hylograph.
Forces. Linkage - Hylograph.
Forces. ManyBody - Hylograph.
Forces. Measure - Hylograph.
Forces. Node - Hylograph.
Forces. Position - Hylograph.
Forces. Quadtree - Hylograph.
Forces. Radial - Hylograph.
Forces. Random - Hylograph.
Forces. RectCollide - Hylograph.
Forces. Snapshot - Hylograph.
Forces. ThreeD - Hylograph.
Forces. ThreeD. Center - Hylograph.
Forces. ThreeD. Collide - Hylograph.
Forces. ThreeD. Link - Hylograph.
Forces. ThreeD. ManyBody - Hylograph.
Forces. ThreeD. Node - Hylograph.
Forces. ThreeD. Octree - Hylograph.
Forces. ThreeD. Position - Hylograph.
Forces. ThreeD. Radial - Hylograph.
Forces. ThreeD. Tick - Hylograph.
Forces. Tick - Hylograph.
Forces. Towards