How do I find hash value of a 3D vector ?
Posted
by brainydexter
on Stack Overflow
See other posts from Stack Overflow
or by brainydexter
Published on 2010-04-06T02:30:04Z
Indexed on
2010/04/06
2:33 UTC
Read the original article
Hit count: 345
I am trying to perform broad-phase collision detection with a fixed-grid size approach. Thus, for each entity's position: (x,y,z) (each of type float), I need to find which cell does the entity lie in. I then intend to store all the cells in a hash-table and then iterate through to report (if any) collisions.
So, here is what I am doing: Grid-cell's position: (int type) (Gx, Gy, Gz) => (x / M, y / M, z / M) where M is the size of the grid.
Once, I have a cell, I'd like to add it to a hash-table with its key being a unique hash based on (Gx, Gy, Gz) and the value being the cell itself. Now, I cannot think of a good hash function and I need some help with that.
Can someone please suggest me a good hash function?
Thanks
© Stack Overflow or respective owner