Skip to content

Commit e229201

Browse files
authored
Use Matrix3X instead of MatrixX3 for correct storage order (#3)
1 parent d71d4d5 commit e229201

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/main.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ struct rerun::ComponentBatchAdapter<rerun::components::Position3D, std::vector<E
2929

3030
// Adapters so we can log an eigen matrix as rerun positions:
3131
template <>
32-
struct rerun::ComponentBatchAdapter<rerun::components::Position3D, Eigen::MatrixX3f> {
32+
struct rerun::ComponentBatchAdapter<rerun::components::Position3D, Eigen::Matrix3Xf> {
3333
// Sanity check that this is binary compatible.
3434
static_assert(
3535
sizeof(components::Position3D) ==
36-
sizeof(Eigen::MatrixX3f::Scalar) * Eigen::MatrixX3f::ColsAtCompileTime
36+
sizeof(Eigen::Matrix3Xf::Scalar) * Eigen::Matrix3Xf::RowsAtCompileTime
3737
);
38-
static_assert(alignof(components::Position3D) <= alignof(Eigen::MatrixX3f));
38+
static_assert(alignof(components::Position3D) <= alignof(Eigen::Matrix3Xf));
3939

40-
ComponentBatch<components::Position3D> operator()(const Eigen::MatrixX3f& matrix) {
40+
ComponentBatch<components::Position3D> operator()(const Eigen::Matrix3Xf& matrix) {
4141
return ComponentBatch<components::Position3D>::borrow(
4242
reinterpret_cast<const components::Position3D*>(matrix.data()),
43-
matrix.rows()
43+
matrix.cols()
4444
);
4545
}
4646

47-
ComponentBatch<components::Position3D> operator()(std::vector<Eigen::MatrixX3f>&& container) {
47+
ComponentBatch<components::Position3D> operator()(std::vector<Eigen::Matrix3Xf>&& container) {
4848
throw std::runtime_error("Not implemented for temporaries");
4949
}
5050
};
@@ -67,8 +67,8 @@ int main() {
6767
const auto points3d_vector = generate_random_points_vector(1000);
6868
rec.log("world/points_from_vector", rerun::Points3D(points3d_vector));
6969

70-
// Points represented by Eigen::MatX3f (Nx3 matrix)
71-
const Eigen::MatrixX3f points3d_matrix = Eigen::MatrixX3f::Random(num_points, 3);
70+
// Points represented by Eigen::Mat3Xf (3xN matrix)
71+
const Eigen::Matrix3Xf points3d_matrix = Eigen::Matrix3Xf::Random(3, num_points);
7272
rec.log("world/points_from_matrix", rerun::Points3D(points3d_matrix));
7373

7474
// Posed pinhole camera:

0 commit comments

Comments
 (0)