散列2D,3D和Nd矢量 [英] Hashing 2D, 3D and nD vectors

查看:372
本文介绍了散列2D,3D和Nd矢量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是良好的散列函数(快捷,周到的分布,少数碰撞)散列的IEEE 32位浮点数组成的二维和三维矢量。我想一般的3D矢量,但算法假定法线(总是在[1,1]),也欢迎。我也并不惧怕位操作为IEEE花车alsways IEEE浮动。

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 algorithms assuming normals (always in [-1,1]) are also welcome. I also do not fear bit-manipulation as IEEE floats are alsways IEEE floats.

另一个更普遍的问题是散列法的Nd浮动向量,其中N是相当小的(3-12)和恒定的,但不是在编译时未知。目前,我只是把这些浮标的uints和XOR在一起,这可能不是最好的解决方案。

Another more general problem is hashing an Nd float-vector, where N is quite small (3-12) and constant but not known at compile time. At the moment I just take these floats as uints and XOR them together, which is probably not the best solution.

推荐答案

有一个在优化空间散列用于描述一个空间散列函数碰撞检测变形的对象。他们使用的哈希函数

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

散(X,Y,Z)=(x p1的XORŸP2 XORž   P3)模N

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

其中,P1,P2,P3是大   素数,在我们的例子73856093,   19349663,83492791,分别。该   值n是哈希表的大小。

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

在纸张中,x,y和z是离散坐标;你很可能还使用花车的二进制值。

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

这篇关于散列2D,3D和Nd矢量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆