Hylograph.Forces.ThreeD.Octree
- Package
- purescript-hylograph-forces
- Repository
- afcondon/purescript-hylograph-forces
The part of d3-octree that d3-force-3d uses: build a tree from a set of points, once, and hand it to a force to walk.
Ported from d3-octree 1.1.0 (MIT, Copyright 2017 Vasco Asturiano; itself from d3-quadtree, ISC, Mike Bostock); see LICENSE.
Built the way Hylograph.Forces.Quadtree builds its tree, from the top
down and without mutation, and for the same reason: d3-octree splits a
cube exactly when a second location lands in it, so the tree does not
depend on the order of insertion. What does depend on it is kept: a
leaf's points run newest first, and the extent starts from the unit cube
at the floor of the smallest coordinates and doubles until it covers the
largest. d3-octree's cover measures the side by x alone
(t = x1 - x0 || 1) and doubles all three axes together, so the extent
is always a cube.
The eight octants of a branch are in d3-octree's order, the index being
deep << 2 | bottom << 1 | right, where right is x >= middle, bottom
y >= middle and deep z >= middle. Its visit takes them in that
order.
One thing d3-quadtree does not do. addAll keeps the coordinates in
Float64Arrays, and a point with a NaN coordinate is skipped when they
are filled, so its slots stay 0: it is left out of the extent, and then
inserted all the same, at (0, 0, 0). (d3-quadtree's plain arrays leave
the slot undefined, and add drops the point.) Such a point descends
the tree as if it were at the origin, but where it is the leaf that a
later point is compared with or split from, its own coordinates are read
again (xp = +tree._x.call(null, node.data)), and they are NaN. Where
it lands then depends on the order of insertion, so when any point has a
NaN coordinate this module builds the tree as d3-octree does, one point
at a time (insert).
#Octree Source
data Octree itemAn octree. A Leaf holds its newest point and then the older points at
the same location, newest first. A Branch holds its eight octants in
d3-octree's order (see the module's head).
Constructors
- 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