Added unit() to Rot2 as syntactic sugar
parent
06fd0335cc
commit
d0507535cd
|
@ -171,6 +171,11 @@ namespace gtsam {
|
|||
Point2 unrotate(const Point2& p, boost::optional<Matrix&> H1 =
|
||||
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:
|
||||
/** Serialization function */
|
||||
friend class boost::serialization::access;
|
||||
|
|
|
@ -33,6 +33,13 @@ TEST( Rot2, constructors_and_angle)
|
|||
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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue