Jpp  18.2.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JAnchor.hh
Go to the documentation of this file.
1 #ifndef __JDETECTOR__JANCHOR__
2 #define __JDETECTOR__JANCHOR__
3 
4 #include "JLang/JObjectID.hh"
6 
7 
8 /**
9  * \author mdejong
10  */
11 
12 namespace JDETECTOR {}
13 namespace JPP { using namespace JDETECTOR; }
14 
15 namespace JDETECTOR {
16 
17  using JLANG::JObjectID;
19 
20 
21  /**
22  * Data structure for anchor position on sea bed.
23  */
24  class JAnchor :
25  public JObjectID,
26  public JPosition2D
27  {
28  public:
29  /**
30  * Default constructor.
31  */
32  JAnchor() :
33  JObjectID(),
34  JPosition2D()
35  {}
36 
37 
38  /**
39  * Constructor.
40  *
41  * \param id identifier
42  * \param x x position
43  * \param y y position
44  */
45  JAnchor(const int id,
46  const double x,
47  const double y) :
48  JObjectID(id),
49  JPosition2D(x, y)
50  {}
51 
52 
53  /**
54  * Read JAnchor from input.
55  *
56  * \param in input stream
57  * \param anchor JAnchor
58  * \return input stream
59  */
60  friend inline std::istream& operator>>(std::istream& in, JAnchor& anchor)
61  {
62  int id;
63  double x, y;
64 
65  if (in >> id >> x >> y)
66  anchor = JAnchor(id, x, y);
67 
68  return in;
69  }
70 
71 
72  /**
73  * Write JAnchor to output.
74  *
75  * \param out output stream
76  * \param anchor JAnchor
77  * \return output stream
78  */
79  friend inline std::ostream& operator<<(std::ostream& out, const JAnchor& anchor)
80  {
81  out << anchor.getID();
82  out << ' ';
83  out << anchor.getX();
84  out << ' ';
85  out << anchor.getY();
86 
87  return out;
88  }
89  };
90 
91 
92  /**
93  * Sort anchors in ascending distance from (0,0).
94  *
95  * \param first first anchor
96  * \param second second anchor
97  * \return true if first anchor closer to (0,0); else false
98  */
99  inline bool operator<(const JAnchor& first, const JAnchor& second)
100  {
101  return first.getLengthSquared() < second.getLengthSquared();
102  }
103 }
104 
105 #endif
double getLengthSquared() const
Get length squared.
Definition: JVector2D.hh:188
JAnchor(const int id, const double x, const double y)
Constructor.
Definition: JAnchor.hh:45
bool operator<(const Head &first, const Head &second)
Less than operator.
Definition: JHead.hh:1814
friend std::istream & operator>>(std::istream &in, JAnchor &anchor)
Read JAnchor from input.
Definition: JAnchor.hh:60
double getY() const
Get y position.
Definition: JVector2D.hh:74
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
double getX() const
Get x position.
Definition: JVector2D.hh:63
int getID() const
Get identifier.
Definition: JObjectID.hh:50
Data structure for position in two dimensions.
Definition: JPosition2D.hh:31
friend std::ostream & operator<<(std::ostream &out, const JAnchor &anchor)
Write JAnchor to output.
Definition: JAnchor.hh:79
Auxiliary class for object identification.
Definition: JObjectID.hh:22
Data structure for anchor position on sea bed.
Definition: JAnchor.hh:24
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
JAnchor()
Default constructor.
Definition: JAnchor.hh:32