#ifndef __JDETECTOR__JANCHOR__ #define __JDETECTOR__JANCHOR__ #include "JLang/JObjectID.hh" #include "JGeometry2D/JPosition2D.hh" /** * \author mdejong */ namespace JDETECTOR {} namespace JPP { using namespace JDETECTOR; } namespace JDETECTOR { using JLANG::JObjectID; using JGEOMETRY2D::JPosition2D; /** * Data structure for anchor position on sea bed. */ class JAnchor : public JObjectID, public JPosition2D { public: /** * Default constructor. */ JAnchor() : JObjectID(), JPosition2D() {} /** * Constructor. * * \param id identifier * \param x x position * \param y y position */ JAnchor(const int id, const double x, const double y) : JObjectID(id), JPosition2D(x, y) {} /** * Read JAnchor from input. * * \param in input stream * \param anchor JAnchor * \return input stream */ friend inline std::istream& operator>>(std::istream& in, JAnchor& anchor) { int id; double x, y; if (in >> id >> x >> y) anchor = JAnchor(id, x, y); return in; } /** * Write JAnchor to output. * * \param out output stream * \param anchor JAnchor * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JAnchor& anchor) { out << anchor.getID(); out << ' '; out << anchor.getX(); out << ' '; out << anchor.getY(); return out; } }; /** * Sort anchors in ascending distance from (0,0). * * \param first first anchor * \param second second anchor * \return true if first anchor closer to (0,0); else false */ inline bool operator<(const JAnchor& first, const JAnchor& second) { return first.getLengthSquared() < second.getLengthSquared(); } } #endif