diff --git a/gtsam/geometry/Point2.h b/gtsam/geometry/Point2.h index a99da460b..af5b1fbcd 100644 --- a/gtsam/geometry/Point2.h +++ b/gtsam/geometry/Point2.h @@ -58,7 +58,12 @@ public: /// @{ /// construct from 2D vector - Point2(const Vector& v) : x_(v(0)), y_(v(1)) { assert(v.size() == 2); } + Point2(const Vector& v) { + if(v.size() != 2) + throw std::invalid_argument("Point2 constructor from Vector requires that the Vector have dimension 2"); + x_ = v(0); + y_ = v(1); + } /// @} /// @name Testable diff --git a/gtsam/geometry/Point3.h b/gtsam/geometry/Point3.h index 4d15b65f5..3e7423c0a 100644 --- a/gtsam/geometry/Point3.h +++ b/gtsam/geometry/Point3.h @@ -48,21 +48,24 @@ namespace gtsam { /// @name Standard Constructors /// @{ - ///TODO: comment + /// Default constructor creates a zero-Point3 Point3(): x_(0), y_(0), z_(0) {} - ///TODO: comment - Point3(const Point3 &p) : x_(p.x_), y_(p.y_), z_(p.z_) {} - - ///TODO: comment + /// Construct from x, y, and z coordinates Point3(double x, double y, double z): x_(x), y_(y), z_(z) {} /// @} /// @name Advanced Constructors /// @{ - ///TODO: comment - Point3(const Vector& v) : x_(v(0)), y_(v(1)), z_(v(2)) {} + /// Construct from 3-element vector + Point3(const Vector& v) { + if(v.size() != 3) + throw std::invalid_argument("Point3 constructor from Vector requires that the Vector have dimension 3"); + x_ = v(0); + y_ = v(1); + z_ = v(2); + } /// @} /// @name Testable