2009-08-22 06:23:24 +08:00
|
|
|
/**
|
|
|
|
|
* @file Point2.cpp
|
|
|
|
|
* @brief 2D Point
|
|
|
|
|
* @author Frank Dellaert
|
|
|
|
|
*/
|
|
|
|
|
|
2010-08-20 01:23:19 +08:00
|
|
|
#include <gtsam/geometry/Point2.h>
|
|
|
|
|
#include <gtsam/base/Lie-inl.h>
|
2009-08-22 06:23:24 +08:00
|
|
|
|
2009-08-29 09:22:40 +08:00
|
|
|
using namespace std;
|
|
|
|
|
|
2009-08-22 06:23:24 +08:00
|
|
|
namespace gtsam {
|
|
|
|
|
|
2010-01-10 07:15:06 +08:00
|
|
|
/** Explicit instantiation of base class to export members */
|
2010-01-16 09:16:59 +08:00
|
|
|
INSTANTIATE_LIE(Point2);
|
2010-01-10 07:15:06 +08:00
|
|
|
|
2010-01-08 08:40:17 +08:00
|
|
|
/* ************************************************************************* */
|
|
|
|
|
void Point2::print(const string& s) const {
|
|
|
|
|
cout << s << "(" << x_ << ", " << y_ << ")" << endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************************************************************* */
|
|
|
|
|
bool Point2::equals(const Point2& q, double tol) const {
|
|
|
|
|
return (fabs(x_ - q.x()) < tol && fabs(y_ - q.y()) < tol);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************************************************************* */
|
2010-01-12 10:09:03 +08:00
|
|
|
double Point2::norm() const {
|
|
|
|
|
return sqrt(x_*x_ + y_*y_);
|
2010-01-08 08:40:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************************************************************* */
|
2010-09-26 06:31:48 +08:00
|
|
|
Point2 Point2::transform_to(const Point2& point,
|
|
|
|
|
boost::optional<Matrix&> H1, boost::optional<Matrix&> H2) const {
|
|
|
|
|
if (H1) *H1 = -eye(2);
|
|
|
|
|
if (H2) *H2 = eye(2);
|
|
|
|
|
return point - *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************************************************************* */
|
|
|
|
|
Point2 Point2::transform_from(const Point2& point,
|
|
|
|
|
boost::optional<Matrix&> H1, boost::optional<Matrix&> H2) const {
|
2010-09-27 23:08:51 +08:00
|
|
|
if (H1) *H1 = eye(2);
|
2010-09-26 06:31:48 +08:00
|
|
|
if (H2) *H2 = eye(2);
|
|
|
|
|
return point + *this;
|
|
|
|
|
}
|
2009-08-22 06:23:24 +08:00
|
|
|
|
|
|
|
|
} // namespace gtsam
|