Skip to content

Commit 3466ea2

Browse files
authored
change accessing order for column major (#112)
1 parent df145cb commit 3466ea2

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

include/small_gicp/ann/projective_search.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ struct UnsafeProjectiveSearch {
110110
const int u = uv[0] * index_map.cols();
111111
const int v = uv[1] * index_map.rows();
112112

113-
for (int dv = -search_window_v; dv <= search_window_v; dv++) {
114-
const int v_clamped = border_v(v + dv, index_map.rows());
115-
if (v_clamped < 0 || v_clamped >= index_map.rows()) {
113+
for (int du = -search_window_h; du <= search_window_h; du++) {
114+
const int u_clamped = border_h(u + du, index_map.cols());
115+
if (u_clamped < 0 || u_clamped >= index_map.cols()) {
116116
continue;
117117
}
118118

119-
for (int du = -search_window_h; du <= search_window_h; du++) {
120-
const int u_clamped = border_h(u + du, index_map.cols());
121-
if (u_clamped < 0 || u_clamped >= index_map.cols()) {
119+
for (int dv = -search_window_v; dv <= search_window_v; dv++) {
120+
const int v_clamped = border_v(v + dv, index_map.rows());
121+
if (v_clamped < 0 || v_clamped >= index_map.rows()) {
122122
continue;
123123
}
124124

include/small_gicp/points/eigen.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: MIT
33
#pragma once
44

5+
#include <vector>
56
#include <Eigen/Core>
67
#include <small_gicp/points/traits.hpp>
78

@@ -15,5 +16,30 @@ struct Traits<Eigen::MatrixXd> {
1516
static Eigen::Vector4d point(const Eigen::MatrixXd& points, size_t i) { return Eigen::Vector4d(points(i, 0), points(i, 1), points(i, 2), 1.0); }
1617
};
1718

19+
template <typename Scalar, int D>
20+
struct Traits<std::vector<Eigen::Matrix<Scalar, D, 1>>> {
21+
static_assert(D == 3 || D == 4, "Only 3D and 4D (homogeneous) points are supported");
22+
static_assert(std::is_floating_point<Scalar>::value, "Only floating point types are supported");
23+
24+
using Point = Eigen::Matrix<Scalar, D, 1>;
25+
static size_t size(const std::vector<Point>& points) { return points.size(); }
26+
static bool has_points(const std::vector<Point>& points) { return points.size(); }
27+
static Eigen::Vector4d point(const std::vector<Point>& points, size_t i) {
28+
if constexpr (std::is_same_v<Scalar, double>) {
29+
if constexpr (D == 3) {
30+
return points[i].homogeneous();
31+
} else {
32+
return points[i];
33+
}
34+
} else {
35+
if constexpr (D == 3) {
36+
return points[i].homogeneous().template cast<double>();
37+
} else {
38+
return points[i].template cast<double>();
39+
}
40+
}
41+
}
42+
};
43+
1844
} // namespace traits
1945
} // namespace small_gicp

0 commit comments

Comments
 (0)