HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleapecs-0.9.6Haskell2010

Apecs.Experimental.Util

This module is experimental, and its API might change between point releases. Use at your own risk. -

  • 5 values
  • Packageapecs-0.9.6
  • Exports5
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceUtil.hs

Spatial hashing

5 declarations

The following are helper functions for spatial hashing. Your spatial hash is defined by two vectors;

  • The cell size vector contains real components and dictates how large each cell in your table is in world space units. It is used by quantize to translate a world space coordinate into a table space index vector

  • The table size vector contains integral components and dictates how many cells your field consists of in each direction. It is used by flatten to translate a table-space index vector into a flat integer

valuequantize
  1. :: (Fractional (v a), Integral b, RealFrac a, Functor v)
  2. => v a

    Quantization cell size

  3. -> v a

    Vector to be quantized

  4. -> v b
#

Quantize turns a world-space coordinate into a table-space coordinate by dividing by the given cell size and rounding towards negative infinity.

valueflatten :: (Applicative v, Integral a, Foldable v) => v a -> v a -> Maybe a
#

Turns a table-space vector into an integral index, given some table size vector. Yields Nothing for out-of-bounds queries

valueregion
  1. :: (Enum a, Applicative v, Traversable v)
  2. => v a

    Lower bound for the region

  3. -> v a

    Higher bound for the region

  4. -> [v a]
#

For two table-space vectors indicating a region's bounds, gives a list of the vectors contained between them. This is useful for querying a spatial hash.