Module

Hylograph.ForceEngine.Types

Package
purescript-hylograph-simulation
Repository
afcondon/purescript-hylograph-simulation

Pure Force Engine Types

These types model the data structures needed for force-directed layouts. The force calculations are pure functions over these structures.

Key insight: D3's force functions just mutate vx/vy on nodes. We can call them directly without the simulation wrapper.

#SimNode Source

type SimNode :: Row Type -> Typetype SimNode extra = { index :: Int, vx :: Number, vy :: Number, x :: Number, y :: Number | extra }

A simulation node with position and velocity. This is the minimal structure that D3 force functions expect.

The extra row allows extending with application-specific data. Note: vx, vy, index are added by the FFI initialization function.

#SimulationState Source

type SimulationState :: Row Type -> Row Type -> Typetype SimulationState nodeRow linkData = { alpha :: Number, alphaDecay :: Number, alphaMin :: Number, alphaTarget :: Number, links :: Array (RawLink linkData), nodes :: Array (SimNode nodeRow), running :: Boolean, velocityDecay :: Number }

The complete state of a force simulation. We manage this ourselves instead of letting D3 do it.

#defaultSimParams Source

defaultSimParams :: { alpha :: Number, alphaDecay :: Number, alphaMin :: Number, alphaTarget :: Number, velocityDecay :: Number }

Default simulation parameters

#ManyBodyConfig Source

type ManyBodyConfig = { distanceMax :: Number, distanceMin :: Number, strength :: Number, theta :: Number }

Configuration for a many-body (charge) force

#CollideConfig Source

type CollideConfig = { iterations :: Int, radius :: Number, strength :: Number }

Configuration for a collision force

#LinkConfig Source

type LinkConfig = { distance :: Number, iterations :: Int, strength :: Number }

Configuration for a link force

#CenterConfig Source

type CenterConfig = { strength :: Number, x :: Number, y :: Number }

Configuration for centering force

#ForceXConfig Source

type ForceXConfig = { strength :: Number, x :: Number }

Configuration for X positioning force

#ForceYConfig Source

type ForceYConfig = { strength :: Number, y :: Number }

Configuration for Y positioning force

#RadialConfig Source

type RadialConfig = { radius :: Number, strength :: Number, x :: Number, y :: Number }

Configuration for radial force

#ManyBodyFilteredConfig Source

type ManyBodyFilteredConfig node = { distanceMax :: Number, distanceMin :: Number, filter :: node -> Boolean, strength :: Number, theta :: Number }

Configuration for filtered many-body force Applies charge only to nodes matching the predicate

#RadialFilteredConfig Source

type RadialFilteredConfig node = { filter :: node -> Boolean, radius :: Number, strength :: Number, x :: Number, y :: Number }

Configuration for filtered radial force

#CollideDynamicConfig Source

type CollideDynamicConfig node = { iterations :: Int, radiusAccessor :: node -> Number, strength :: Number }

Configuration for collision force with dynamic radius Radius is computed per-node via accessor function

#ForceXDynamicConfig Source

type ForceXDynamicConfig node = { strength :: Number, xAccessor :: node -> Number }

Configuration for X positioning force with dynamic target Target X is computed per-node via accessor function

#ForceYDynamicConfig Source

type ForceYDynamicConfig node = { strength :: Number, yAccessor :: node -> Number }

Configuration for Y positioning force with dynamic target

#LinkDynamicConfig Source

type LinkDynamicConfig link = { distance :: Number, iterations :: Int, strengthAccessor :: link -> Number }

Configuration for link force with dynamic strength per-link Strength is computed per-link via accessor function

#forceName Source

forceName :: ForceSpec -> String

Get the name of a force