From 0e42a96294a9c8ecbd9649876a89670427e68455 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Thu, 18 Jun 2020 11:09:37 -0500 Subject: [PATCH] Cleaned up printing of Rot3 --- gtsam/geometry/Rot3.cpp | 5 +++-- gtsam/geometry/Rot3.h | 2 +- gtsam/geometry/tests/testRot3.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gtsam/geometry/Rot3.cpp b/gtsam/geometry/Rot3.cpp index 613c5b40f..318655491 100644 --- a/gtsam/geometry/Rot3.cpp +++ b/gtsam/geometry/Rot3.cpp @@ -32,7 +32,8 @@ namespace gtsam { /* ************************************************************************* */ void Rot3::print(const std::string& s) const { - gtsam::print((Matrix)matrix(), s); + cout << (s.empty() ? "R: " : s + " "); + gtsam::print((Matrix)matrix()); } /* ************************************************************************* */ @@ -222,7 +223,7 @@ pair RQ(const Matrix3& A) { /* ************************************************************************* */ ostream &operator<<(ostream &os, const Rot3& R) { - os << R.matrix().format(matlab) << endl; + os << R.matrix().format(matlab); return os; } diff --git a/gtsam/geometry/Rot3.h b/gtsam/geometry/Rot3.h index fc3a8b3f2..8ab7dd377 100644 --- a/gtsam/geometry/Rot3.h +++ b/gtsam/geometry/Rot3.h @@ -254,7 +254,7 @@ namespace gtsam { /// @{ /** print */ - void print(const std::string& s="R") const; + void print(const std::string& s="") const; /** equals with an tolerance */ bool equals(const Rot3& p, double tol = 1e-9) const; diff --git a/gtsam/geometry/tests/testRot3.cpp b/gtsam/geometry/tests/testRot3.cpp index 4e3a6d85e..d5400494e 100644 --- a/gtsam/geometry/tests/testRot3.cpp +++ b/gtsam/geometry/tests/testRot3.cpp @@ -608,7 +608,7 @@ TEST( Rot3, stream) Rot3 R; std::ostringstream os; os << R; - string expected = "[\n\t1, 0, 0;\n\t0, 1, 0;\n\t0, 0, 1\n]\n"; + string expected = "[\n\t1, 0, 0;\n\t0, 1, 0;\n\t0, 0, 1\n]"; EXPECT(os.str() == expected); }