Hashing 2D, 3D and nD vectors

前端 未结 3 663
春和景丽
春和景丽 2020-12-07 16:48

What are good hashing functions (fast, good distribution, few collisions) for hashing 2d and 3d vectors composed of IEEE 32bit floats. I assume general 3d vectors, but algor

3条回答
  •  借酒劲吻你
    2020-12-07 17:24

    There's a spatial hash function described in Optimized Spatial Hashing for Collision Detection of Deformable Objects. They use the hash function

    hash(x,y,z) = ( x p1 xor y p2 xor z p3) mod n

    where p1, p2, p3 are large prime numbers, in our case 73856093, 19349663, 83492791, respectively. The value n is the hash table size.

    In the paper, x, y, and z are the discretized coordinates; you could probably also use the binary values of your floats.

提交回复
热议问题