Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
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
12namespace JDETECTOR {}
13namespace JPP { using namespace JDETECTOR; }
14
15namespace 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 */
33 JObjectID(),
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
Data structure for anchor position on sea bed.
Definition JAnchor.hh:27
friend std::istream & operator>>(std::istream &in, JAnchor &anchor)
Read JAnchor from input.
Definition JAnchor.hh:60
JAnchor()
Default constructor.
Definition JAnchor.hh:32
friend std::ostream & operator<<(std::ostream &out, const JAnchor &anchor)
Write JAnchor to output.
Definition JAnchor.hh:79
JAnchor(const int id, const double x, const double y)
Constructor.
Definition JAnchor.hh:45
Data structure for position in two dimensions.
double getY() const
Get y position.
Definition JVector2D.hh:74
double getX() const
Get x position.
Definition JVector2D.hh:63
double getLengthSquared() const
Get length squared.
Definition JVector2D.hh:188
Auxiliary class for object identification.
Definition JObjectID.hh:25
int getID() const
Get identifier.
Definition JObjectID.hh:50
file Auxiliary data structures and methods for detector calibration.
Definition JAnchor.hh:12
bool operator<(const JAnchor &first, const JAnchor &second)
Sort anchors in ascending distance from (0,0).
Definition JAnchor.hh:99
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).