散列 2D、3D 和 nD 向量
用于对由 IEEE 32 位浮点数组成的 2d 和 3d 向量进行哈希处理的良好哈希函数(快速、分布良好、冲突少)是什么?我假设一般的 3d 向量,但假设法线(始终在 [-1,1] 中)的算法也受到欢迎。我也不担心位操作,因为 IEEE 浮点数始终是 IEEE 浮点数。
另一个更普遍的问题是对 Nd 浮点向量进行哈希处理,其中 N 非常小(3-12)并且是常数,但在编译时未知。目前,我只是将这些浮点数作为 uint 并将它们异或在一起,这可能不是最好的解决方案。
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
用于可变形对象碰撞检测的优化空间哈希中描述了一个空间哈希函数。他们使用哈希函数
论文中,x、y、z为离散化坐标;您可能还可以使用浮点数的二进制值。
There's a spatial hash function described in Optimized Spatial Hashing for Collision Detection of Deformable Objects. They use the hash function
In the paper, x, y, and z are the discretized coordinates; you could probably also use the binary values of your floats.
我有两个建议。
现在,如果您不进行量化, ,它不会对邻近性(局部性)敏感。
I have two suggestions.
If you don't do the quantization, it wont be sensitive to closeness(locality).
我根据这里看到的评论用 Python 写了这个,
它
看起来很有效。
在 C++ 中
I wrote this in Python based on the comments seen here,
It gives
It seemed to work.
In C++