HashGrid3D

class HashGrid3D(val radius: Double)(source)

Represents a 3D Hash Grid structure used for spatial partitioning of points in 3D space. This structure organizes points into grid-based cells, enabling efficient spatial querying and insertion operations.

Constructors

Link copied to clipboard
constructor(radius: Double)

Properties

Link copied to clipboard

The size of a single cell in the 3D hash grid.

Link copied to clipboard

The radius used to determine proximity checks within the grid. Points are considered neighbors if their spatial distance is less than or equal to this radius.

Link copied to clipboard
var size: Int

Represents the total number of points currently stored in the hash grid. This property is incremented whenever a new point is inserted into the grid. It's read-only for external access and cannot be modified outside the class.

Functions

Link copied to clipboard
fun cell(query: Vector3): Cell3D?

Retrieves the 3D cell corresponding to the given query point in the spatial hash grid.

Link copied to clipboard

Returns a sequence of all the cells present in the hash grid. Each cell is yielded individually from the internal mapping.

Link copied to clipboard
fun insert(point: Vector3, owner: Any? = null)
Link copied to clipboard
fun isFree(query: Vector3, ignoreOwners: Set<Any> = emptySet()): Boolean

Determines whether a specific point in the 3D grid is free, considering the proximity to other points and optionally ignoring specified owners.

Link copied to clipboard
fun points(): Sequence<Pair<Vector3, Any?>>

Returns a sequence of all points contained in the hash grid.

Link copied to clipboard
fun random(random: Random = Random.Default): Vector3

Selects a random 3D vector from the points stored in the hash grid.