diff --git a/cpp/Point2.h b/cpp/Point2.h index 0568445e7..32fd57dfe 100644 --- a/cpp/Point2.h +++ b/cpp/Point2.h @@ -48,6 +48,7 @@ namespace gtsam { /** operators */ inline bool operator ==(const Point2& q) const {return x_==q.x_ && q.y_==q.y_;} inline Point2 operator + (const Point2& q) const {return Point2(x_+q.x_,y_+q.y_);} + inline Point2 operator + (double value) const {return Point2(x_+value,y_+value);} inline Point2 operator - (const Point2& q) const {return Point2(x_-q.x_,y_-q.y_);} inline Point2 operator / (double q) const {return Point2(x_/q,y_/q);} diff --git a/cpp/testPoint2.cpp b/cpp/testPoint2.cpp index 580b63401..951fc4777 100644 --- a/cpp/testPoint2.cpp +++ b/cpp/testPoint2.cpp @@ -22,6 +22,11 @@ TEST( Point2, add) { CHECK(assert_equal( Point2(4,5)+Point2(1,1), Point2(5,6) )); } +/* ************************************************************************* */ +TEST( Point2, addScalar) { + CHECK(assert_equal( Point2(4,5)+1, Point2(5,6) )); +} + /* ************************************************************************* */ TEST( Point2, subtract) { CHECK(assert_equal( Point2(4,5)-Point2(1,1), Point2(3,4) ));