Add quadtree nearestToPoint, and Readwrite locking (#217)

This commit is contained in:
Jonathan Ellis
2022-01-18 12:36:28 -06:00
committed by GitHub
parent 398b155a78
commit 3993085197
3 changed files with 136 additions and 5 deletions

View File

@@ -0,0 +1,45 @@
package org.openrndr.extra.quadtree
import org.openrndr.math.Vector2
interface IQuadtree<T> {
/**
* Clears the whole tree
*/
fun clear()
/**
* Finds the nearest and neighbouring objects within a radius
* (needs to have a different name so there is no ambiguity when the generic object type is Vector2)
*
* @param element
* @param radius
* @return
*/
fun nearestToPoint(point: Vector2, radius: Double): QuadtreeQuery<T>?
/**
* Finds the nearest and neighbouring points within a radius
*
* @param element
* @param radius
* @return
*/
fun nearest(element: T, radius: Double): QuadtreeQuery<T>?
/**
* Inserts the element in the appropriate node
*
* @param element
* @return
*/
fun insert(element: T): Boolean
/**
* Finds which node the element is within (but not necessarily belonging to)
*
* @param element
* @return
*/
fun findNode(element: T): Quadtree<T>?
}