Added unit() to Rot2 as syntactic sugar

release/4.3a0
Alex Cunningham 2011-09-02 01:50:12 +00:00
parent 06fd0335cc
commit d0507535cd
2 changed files with 12 additions and 0 deletions

View File

@ -171,6 +171,11 @@ namespace gtsam {
Point2 unrotate(const Point2& p, boost::optional<Matrix&> H1 = Point2 unrotate(const Point2& p, boost::optional<Matrix&> H1 =
boost::none, boost::optional<Matrix&> H2 = boost::none) const; boost::none, boost::optional<Matrix&> H2 = boost::none) const;
/**
* Creates a unit vector as a Point2
*/
inline Point2 unit() const { return Point2(c_, s_); }
private: private:
/** Serialization function */ /** Serialization function */
friend class boost::serialization::access; friend class boost::serialization::access;

View File

@ -33,6 +33,13 @@ TEST( Rot2, constructors_and_angle)
CHECK(assert_equal(R,Rot2::atan2(s*5,c*5))); CHECK(assert_equal(R,Rot2::atan2(s*5,c*5)));
} }
/* ************************************************************************* */
TEST( Rot2, unit)
{
EXPECT(assert_equal(Point2(1.0, 0.0), Rot2::fromAngle(0).unit()));
EXPECT(assert_equal(Point2(0.0, 1.0), Rot2::fromAngle(M_PI_2).unit()));
}
/* ************************************************************************* */ /* ************************************************************************* */
TEST( Rot2, transpose) TEST( Rot2, transpose)
{ {