Fixed comments and error messages in Point2 and Point3 constructors

release/4.3a0
Richard Roberts 2012-08-22 22:40:22 +00:00
parent 5ddd28ba18
commit dd34792e7e
2 changed files with 16 additions and 8 deletions

View File

@ -58,7 +58,12 @@ public:
/// @{ /// @{
/// construct from 2D vector /// 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 /// @name Testable

View File

@ -48,21 +48,24 @@ namespace gtsam {
/// @name Standard Constructors /// @name Standard Constructors
/// @{ /// @{
///TODO: comment /// Default constructor creates a zero-Point3
Point3(): x_(0), y_(0), z_(0) {} Point3(): x_(0), y_(0), z_(0) {}
///TODO: comment /// Construct from x, y, and z coordinates
Point3(const Point3 &p) : x_(p.x_), y_(p.y_), z_(p.z_) {}
///TODO: comment
Point3(double x, double y, double z): x_(x), y_(y), z_(z) {} Point3(double x, double y, double z): x_(x), y_(y), z_(z) {}
/// @} /// @}
/// @name Advanced Constructors /// @name Advanced Constructors
/// @{ /// @{
///TODO: comment /// Construct from 3-element vector
Point3(const Vector& v) : x_(v(0)), y_(v(1)), z_(v(2)) {} 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 /// @name Testable