Skip to content

Commit 421a037

Browse files
committed
Slight code cleanup
1 parent 151b47f commit 421a037

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <opencv2/imgproc.hpp>
88
#include <rerun.hpp>
99

10+
// Adapters so we can log eigen vectors as rerun positions:
1011
template <>
1112
struct rerun::ComponentBatchAdapter<rerun::components::Position3D, std::vector<Eigen::Vector3f>> {
1213
// Sanity check that this is binary compatible.
@@ -26,6 +27,7 @@ struct rerun::ComponentBatchAdapter<rerun::components::Position3D, std::vector<E
2627
}
2728
};
2829

30+
// Adapters so we can log an eigen matrix as rerun positions:
2931
template <>
3032
struct rerun::ComponentBatchAdapter<rerun::components::Position3D, Eigen::MatrixX3f> {
3133
// Sanity check that this is binary compatible.
@@ -62,11 +64,11 @@ int main() {
6264
const int num_points = 1000;
6365

6466
// Points represented by std::vector<Eigen::Vector3f>
65-
auto points3d_vector = generate_random_points_vector(1000);
67+
const auto points3d_vector = generate_random_points_vector(1000);
6668
rec.log("world/points_from_vector", rerun::Points3D(points3d_vector));
6769

6870
// Points represented by Eigen::MatX3f (Nx3 matrix)
69-
Eigen::MatrixX3f points3d_matrix = Eigen::MatrixX3f::Random(num_points, 3);
71+
const Eigen::MatrixX3f points3d_matrix = Eigen::MatrixX3f::Random(num_points, 3);
7072
rec.log("world/points_from_matrix", rerun::Points3D(points3d_matrix));
7173

7274
// Posed pinhole camera
@@ -84,7 +86,7 @@ int main() {
8486
))
8587
.with_resolution(rerun::components::Resolution({width, height}))
8688
);
87-
Eigen::Vector3f camera_position{0.0, -1.0, 0.0};
89+
const Eigen::Vector3f camera_position{0.0, -1.0, 0.0};
8890
Eigen::Matrix3f camera_orientation;
8991
// clang-format off
9092
camera_orientation <<
@@ -95,8 +97,9 @@ int main() {
9597
rec.log(
9698
"world/camera",
9799
rerun::Transform3D(
98-
rerun::datatypes::Vec3D(*reinterpret_cast<float(*)[3]>(camera_position.data())),
99-
rerun::datatypes::Mat3x3(*reinterpret_cast<float(*)[9]>(camera_orientation.data()))
100+
rerun::datatypes::Vec3D(*reinterpret_cast<const float(*)[3]>(camera_position.data())),
101+
rerun::datatypes::Mat3x3(*reinterpret_cast<const float(*)[9]>(camera_orientation.data())
102+
)
100103
)
101104
);
102105

0 commit comments

Comments
 (0)