ostream << operator

release/4.3a0
Frank Dellaert 2013-06-06 01:21:34 +00:00
parent 640fcd94b1
commit 1251ba9abb
3 changed files with 19 additions and 0 deletions

View File

@ -348,4 +348,11 @@ namespace gtsam {
Point3 t = Point3(cq) - R * Point3(cp); Point3 t = Point3(cq) - R * Point3(cp);
return Pose3(R, t); return Pose3(R, t);
} }
/* ************************************************************************* */
std::ostream &operator<<(std::ostream &os, const Pose3& pose) {
os << pose.rotation() << "\n" << pose.translation() << endl;
return os;
}
} // namespace gtsam } // namespace gtsam

View File

@ -290,6 +290,9 @@ namespace gtsam {
*/ */
static std::pair<size_t, size_t> rotationInterval() { return std::make_pair(0, 2); } static std::pair<size_t, size_t> rotationInterval() { return std::make_pair(0, 2); }
/// Output stream operator
friend std::ostream &operator<<(std::ostream &os, const Pose3& p);
private: private:
/** Serialization function */ /** Serialization function */
friend class boost::serialization::access; friend class boost::serialization::access;

View File

@ -741,6 +741,15 @@ TEST( Pose3, adjointTranspose) {
EXPECT(assert_equal(numericalH,actualH,1e-5)); EXPECT(assert_equal(numericalH,actualH,1e-5));
} }
/* ************************************************************************* */
TEST( Pose3, stream)
{
Pose3 T;
std::ostringstream os;
os << T;
EXPECT(os.str() == "\n|1, 0, 0|\n|0, 1, 0|\n|0, 0, 1|\n\n(0, 0, 0)\n");
}
/* ************************************************************************* */ /* ************************************************************************* */
int main(){ TestResult tr; return TestRegistry::runAllTests(tr);} int main(){ TestResult tr; return TestRegistry::runAllTests(tr);}
/* ************************************************************************* */ /* ************************************************************************* */