Module

Hylograph.Forces.ThreeD.Link

Package
purescript-hylograph-forces
Repository
afcondon/purescript-hylograph-forces

The link force in three dimensions: each link is a spring that pulls its two nodes towards a set distance apart.

Ported from d3-force-3d 3.0.6, link.js (MIT, Copyright 2017 Vasco Asturiano; itself from d3-force, ISC, Mike Bostock); see LICENSE. It is d3-force's link.js with a third coordinate and nothing else.

The joining of links to nodes (Hylograph.Forces.Linkage: degrees, bias, by place or by id) has no dimension and is the two-dimensional force's.

#Config Source

type Config link = { distance :: link -> Number, iterations :: Int, strength :: Strength link }

forceLink settings. distance is asked once per link.

#Strength Source

data Strength link

How stiff each spring is.

#strengthFromDegree Source

strengthFromDegree :: forall link. Strength link

d3's default: 1 / min(degree of source, degree of target).

#defaultConfig Source

defaultConfig :: forall link. Config link

d3's defaults: distance 30, strength from degree, one iteration.

#initialize Source

initialize :: forall row linkRow. Config (Endpoints linkRow) -> Source -> Array (Node row) -> Array (Endpoints linkRow) -> Link row

force.initialize(nodes, random, 3) together with force.links(links), for links that name their nodes by place in the node array. A link naming a place outside the array is dropped.

#initializeById Source

initializeById :: forall id row linkRow. Ord id => Show id => (Node row -> id) -> Config (Identified id linkRow) -> Source -> Array (Node row) -> Array (Identified id linkRow) -> Either String (Link row)

The same for links that name their nodes by id; a link naming an id that no node has is d3's error, node not found: <id>.

#apply Source

apply :: forall row. Link row -> Number -> Effect Unit

d3-force-3d's force(alpha). Links are taken in order and each sees what the ones before it did.

x = target.x + target.vx - source.x - source.vx || jiggle(random);
y = target.y + target.vy - source.y - source.vy || jiggle(random);
z = target.z + target.vz - source.z - source.vz || jiggle(random);

Re-exports from Hylograph.Forces.Linkage

#Identified Source

type Identified :: Type -> Row Type -> Typetype Identified id row = { source :: id, target :: id | row }

A link, by the ids of its two nodes.

#Endpoints Source

type Endpoints :: Row Type -> Typetype Endpoints row = { source :: Int, target :: Int | row }

A link, by the places of its two nodes in the node array.