Options
All
• Public
• Public/Protected
• All

# Class Kdtree

Kdtree

class
author

Alexander Rose alexander.rose@weirdbyte.de, 2016

author

Roman Bolzern roman.bolzern@fhnw.ch, 2013

author

I4DS http://www.fhnw.ch/i4ds, 2013

description

k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place provides fast nearest neighbour search

Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs

Further information (including mathematical properties) http://en.wikipedia.org/wiki/Binary_tree http://en.wikipedia.org/wiki/K-d_tree

example

points: [x, y, z, x, y, z, x, y, z, ...] metric: function(a, b){ return Math.pow(a-b, 2) + Math.pow(a-b, 2) + Math.pow(a-b, 2); }

param

points

param

metric

• Kdtree

## Constructors

### constructor

• new Kdtree(points: Float32Array, metric: function): Kdtree

## Properties

### atomIndices

atomIndices: Uint32Array

### currentNode

currentNode: number = 0

### indices

indices: Uint32Array

kdtree: _Kdtree

### maxDepth

maxDepth: number = 0

metric: function

### nodes

nodes: Int32Array

### points

points: Float32Array

### rootIndex

rootIndex: number

## Methods

### buildTree

• buildTree(depth: number, parent: number, arrBegin: number, arrEnd: number): number

### getNodeDepth

• getNodeDepth(nodeIndex: number): number

### nearest

• nearest(point: NumberArray, maxNodes: number, maxDistance: number): Object[]
• find nearest points

#### Parameters

• ##### point: NumberArray

array of size 3

• ##### maxNodes: number

max amount of nodes to return

• ##### maxDistance: number

maximum distance of point to result nodes

#### Returns Object[]

array of point, distance pairs

### verify

• verify(nodeIndex?: undefined | number, depth?: number): number

#### Returns number

Generated using TypeDoc