Skip to content

impopular-guy/kdbush

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kdbush

A static spacial index for 2D points in V. This is a V port of kdbush Go.

Install

v install impopular-guy.kdbush

Usage

import impopular_guy.kdbush

interface Point

interface Point {
	coordinates() (f64, f64)
}

You can use objects that implements Point interface or you can also use kdbush.SimplePoint which also implements the interface.

KDBush.new

fn KDBush.new(points []Point, node_size int) &KDBush

KDBush.new takes objects as input and builds the index.

It takes the following inputs:
points - array of objects, that implements Point interface
node_size - size of the KD-tree node (i.e 64). Higher means faster indexing but slower search, and vise versa.

range

fn (bush KDBush) range(minX f64, minY f64, maxX f64, maxY f64) []int

range finds all items within the given bounding box and returns an array of indices that refer to the items in the original points input slice.

within

fn (bush KDBush) within(qx f64, qy f64, radius f64) []int

within finds all items within a given radius from the query point and returns an array of indices.

LICENSE

MIT

Releases

No releases published

Packages

No packages published

Languages