Added stream operator << and renamed dist to distance
parent
84903d05c2
commit
7fcdc467c1
|
@ -40,4 +40,10 @@ double Point2::norm() const {
|
||||||
return sqrt(x_*x_ + y_*y_);
|
return sqrt(x_*x_ + y_*y_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
ostream &operator<<(ostream &os, const Point2& p) {
|
||||||
|
os << '(' << p.x() << ", " << p.y() << ')';
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace gtsam
|
} // namespace gtsam
|
||||||
|
|
|
@ -151,6 +151,11 @@ public:
|
||||||
Point2 unit() const { return *this/norm(); }
|
Point2 unit() const { return *this/norm(); }
|
||||||
|
|
||||||
/** distance between two points */
|
/** distance between two points */
|
||||||
|
inline double distance(const Point2& p2) const {
|
||||||
|
return (p2 - *this).norm();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @deprecated The following function has been deprecated, use distance above */
|
||||||
inline double dist(const Point2& p2) const {
|
inline double dist(const Point2& p2) const {
|
||||||
return (p2 - *this).norm();
|
return (p2 - *this).norm();
|
||||||
}
|
}
|
||||||
|
@ -184,6 +189,9 @@ public:
|
||||||
inline void operator *= (double s) {x_*=s;y_*=s;}
|
inline void operator *= (double s) {x_*=s;y_*=s;}
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
/// Streaming
|
||||||
|
friend std::ostream &operator<<(std::ostream &os, const Point2& p);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/// @name Advanced Interface
|
/// @name Advanced Interface
|
||||||
|
|
Loading…
Reference in New Issue