small_gicp
vector3i_hash.hpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright 2024 Kenji Koide
2 // SPDX-License-Identifier: MIT
3 #pragma once
4 
5 #include <Eigen/Core>
6 
7 namespace small_gicp {
8 
14 public:
15  size_t operator()(const Eigen::Vector3i& x) const {
16  const size_t p1 = 73856093;
17  const size_t p2 = 19349669; // 19349663 was not a prime number
18  const size_t p3 = 83492791;
19  return static_cast<size_t>((x[0] * p1) ^ (x[1] * p2) ^ (x[2] * p3));
20  }
21 
22  static size_t hash(const Eigen::Vector3i& x) { return XORVector3iHash()(x); }
23  static bool equal(const Eigen::Vector3i& x1, const Eigen::Vector3i& x2) { return x1 == x2; }
24 };
25 
26 } // namespace small_gicp
Definition: flat_container.hpp:12
Spatial hashing function. Teschner et al., "Optimized Spatial Hashing for Collision Detection of Defo...
Definition: vector3i_hash.hpp:13
size_t operator()(const Eigen::Vector3i &x) const
Definition: vector3i_hash.hpp:15
static bool equal(const Eigen::Vector3i &x1, const Eigen::Vector3i &x2)
Definition: vector3i_hash.hpp:23
static size_t hash(const Eigen::Vector3i &x)
Definition: vector3i_hash.hpp:22