Hylograph.Forces.Measure
- Package
- purescript-hylograph-forces
- Repository
- afcondon/purescript-hylograph-forces
Measures of how settled a layout is. The definitions are the Rust
kernel's (kinetic_energy, max_displacement, max_acceleration and
settled in force-kernel/src/lib.rs), and test/differential.mjs
holds the two to each other bit for bit.
Kinetic energy is read off the nodes. The other three need to know
where the nodes were, so they are kept by a Watch: tell it when a tick
begins and when it ends, and ask it afterwards.
#kineticEnergy Source
kineticEnergy :: forall row. Array (Node row) -> Effect NumberKinetic energy, taking every node to have unit mass: the sum over the
nodes, in order, of vx * vx and then vy * vy, halved. After a tick
the velocity is the step the node took in it, so this falls toward zero
as the layout settles.
#after Source
after :: forall row. Watch -> Array (Node row) -> Effect UnitCall when the tick has ended: work out how far each node moved and how that differs from its step the tick before.
The largest change of step is only meaningful from the second tick on;
until then maxAcceleration is zero and settled is false.
#maxDisplacement Source
maxDisplacement :: Watch -> Effect NumberThe furthest any node moved in the last tick: the largest distance between where a node was when the tick began and where it ended, everything included (forces, centring, clamps, pins). Zero before the first tick.
#maxAcceleration Source
maxAcceleration :: Watch -> Effect NumberThe largest change in any node's step between the last two ticks: the acceleration it actually underwent. A node on a spring is momentarily still at the far end of every swing, where energy and displacement vanish and this is at its largest. Zero until two ticks have been seen.
- 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. Tick - Hylograph.
Forces. Towards