Jpp  master_rocky-43-ge265d140c
the software that should make you happy
examples/JAcoustics/JSeabed.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 #include <vector>
5 
6 #include "JDetector/JTripod.hh"
7 
8 #include "JMath/JSVD3D.hh"
9 
10 #include "Jeep/JContainer.hh"
11 #include "Jeep/JParser.hh"
12 #include "Jeep/JMessage.hh"
13 
14 
15 /**
16  * \file
17  * Auxiliary application to determine tilt angles of seabed based on tripod positions.
18  *
19  * \author mdejong
20  */
21 int main(int argc, char **argv)
22 {
23  using namespace std;
24  using namespace JPP;
25 
27 
28  tripods_container tripods;
29  int debug;
30 
31  try {
32 
33  JParser<> zap("Auxiliary application to determine tilt angles of seabed based on tripod positions.");
34 
35  zap['T'] = make_field(tripods);
36  zap['d'] = make_field(debug) = 1;
37 
38  zap(argc, argv);
39  }
40  catch(const exception& error) {
41  FATAL(error.what() << endl);
42  }
43 
44  if (tripods.size() < 3) {
45  FATAL("Number of tripods " << tripods.size() << endl);
46  }
47 
48  // center
49 
50  JUTMPosition pos(0.0, 0.0, 0.0);
51 
52  for (tripods_container::const_iterator i = tripods.begin(); i != tripods.end(); ++i) {
53  pos += i->getUTMPosition();
54  }
55 
56  pos /= tripods.size();
57 
58  DEBUG("center: "
59  << showpos << FIXED(12,3) << pos.getX() << ' '
60  << showpos << FIXED(12,3) << pos.getY() << ' '
61  << showpos << FIXED(12,3) << pos.getZ() << endl);
62 
63  // solve z(x,y) = a*x + b*y + c
64 
65  JMatrix3D A;
66  double Y[3] = { 0.0, 0.0, 0.0 };
67 
68  for (tripods_container::const_iterator i = tripods.begin(); i != tripods.end(); ++i) {
69 
70  const double x = i->getX() - pos.getX();
71  const double y = i->getY() - pos.getY();
72  const double z = i->getZ() - pos.getZ();
73 
74  A.a00 += x * x; A.a01 += x * y; A.a02 += x;
75  A.a10 += x * y; A.a11 += y * y; A.a12 += y;
76  A.a20 += x; A.a21 += y; A.a22 += 1.0;
77 
78  Y[0] += x * z;
79  Y[1] += y * z;
80  Y[2] += z;
81  }
82 
83  DEBUG(A);
84 
85  JSVD3D V(A);
86 
87  try {
88 
89  A = V.invert();
90 
91  const double a = A.a00 * Y[0] + A.a01 * Y[1] + A.a02 * Y[2];
92  const double b = A.a10 * Y[0] + A.a11 * Y[1] + A.a12 * Y[2];
93  //const double c = A.a20 * Y[0] + A.a21 * Y[1] + A.a22 * Y[2];
94  /*
95  const double Rx = atan(+b); // rotation aroud x-axis
96  const double Ry = atan(-a); // rotation aroud y-axis
97 
98  cout << showpos << FIXED(12,6) << Rx << ' '
99  << showpos << FIXED(12,6) << Ry << endl;
100  */
101 
102  const double Tx = a;
103  const double Ty = b;
104 
105  cout << showpos << FIXED(12,6) << Tx << ' '
106  << showpos << FIXED(12,6) << Ty << endl;
107  }
108  catch(const exception& error) {
109  FATAL(error.what());
110  }
111 
112  return 0;
113 }
Container I/O.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Data structure for tripod.
Singular value decomposition.
Definition: JSVD3D.hh:27
const JMatrix3D & invert(const double precision=1.0e-12) const
Get inverted matrix.
Definition: JSVD3D.hh:192
Utility class to parse command line options.
Definition: JParser.hh:1698
Data structure for UTM position.
Definition: JUTMPosition.hh:38
double getZ() const
Get z.
double getY() const
Get y.
double getX() const
Get x.
const JUTMPosition & getUTMPosition() const
Get UTM position.
Definition: JUTMPosition.hh:84
int main(int argc, char **argv)
const double a
Definition: JQuadrature.cc:42
JContainer< std::vector< JTripod > > tripods_container
Definition: JSydney.cc:78
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:448
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Definition: JContainer.hh:42