-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDF_XY_Report.hpp
159 lines (142 loc) · 4.78 KB
/
DF_XY_Report.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// DFLib: A library of Bearings Only Target Localization algorithms
// Copyright (C) 2009-2015 Thomas V. Russo
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// Filename : $RCSfile$
//
// Purpose : Simple "Report" class for DF reports specified in a
// generic X-Y coordinate system.
//
// Special Notes : This is not especially useful in real DF operations, unless
// one is using a well-chosen X-Y coordinate system. It is
// primarily useful as a debugging tool or for more
// theoretical studies.
//
// Creator :
//
// Creation Date :
//
// Revision Information:
// ---------------------
//
// Revision Number: $Revision$
//
// Revision Date : $Date$
//
// Current Owner : $Author$
//-------------------------------------------------------------------------
#ifndef DF_XY_REPORT_HPP
#define DF_XY_REPORT_HPP
#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#endif
#include "DFLib_port.h"
#include <cmath>
#include "DF_Abstract_Report.hpp"
namespace DFLib
{
namespace XY
{
class Point;
/// \brief DF report in XY coordinates
/// This class is meant for simplistic DF codes that work in X/Y
/// coordinates already. Mostly intended for testing the interface.
class CPL_DLL Report
: public DFLib::Abstract::Report
{
private:
Point receiverLocation;
double bearing,sigma;
public:
Report(const std::vector<double> &theLocation,
const double &bearing,const double &std_dev,
const std::string &theName);
~Report();
virtual const std::vector<double> &getReceiverLocation();
virtual double getReportBearingRadians() const;
virtual double getBearing() const;
virtual double getBearingStandardDeviationRadians() const;
virtual double getSigma() const;
virtual void setReceiverLocation(std::vector<double> &theLocation);
//! set bearing in degrees
virtual void setBearing(double Bearing);
//! set standard deviation in degrees
virtual void setSigma(double Sigma);
};
}
/// \brief XYDF report constructor.
/// \param theLocation position vector of this report.
/// \param Bearing bearing IN DEGREES
/// \param std_dev standard deviation in degrees
inline DFLib::XY::Report::Report(const std::vector<double> &theLocation,
const double &Bearing,const double &std_dev,
const std::string &theName)
: DFLib::Abstract::Report(theName,true),
receiverLocation(theLocation),
bearing(Bearing*M_PI/180.0),
sigma(std_dev*M_PI/180.0)
{
// Make sure our bearing is *always* 0<=bearing<2pi. If it isn't,
// reset it:
while (bearing < 0)
bearing += 2*M_PI;
while (bearing >= 2*M_PI)
bearing -= 2*M_PI;
}
inline DFLib::XY::Report::~Report()
{
}
inline double DFLib::XY::Report::getReportBearingRadians() const
{
// bearing *must* be in 0<bearing<2*pi
return bearing;
}
inline double DFLib::XY::Report::getBearing() const
{
// always return bearing in range 0-360 degrees
return (getReportBearingRadians()*180.0/M_PI);
}
inline double DFLib::XY::Report::getBearingStandardDeviationRadians() const
{
return sigma;
}
inline double DFLib::XY::Report::getSigma() const
{
return sigma*180/M_PI;
}
inline void DFLib::XY::Report::setReceiverLocation(std::vector<double> &theLocation)
{
receiverLocation.setXY(theLocation);
}
inline const std::vector<double> & DFLib::XY::Report::getReceiverLocation()
{
return receiverLocation.getXY();
}
inline void DFLib::XY::Report::setBearing(double Bearing)
{
// bearing *must* be in 0<=bearing<2*pi
bearing=Bearing*M_PI/180.0;
while (bearing < 0)
bearing += 2*M_PI;
while (bearing >= 2*M_PI)
bearing -= 2*M_PI;
}
inline void DFLib::XY::Report::setSigma(double Sigma)
{
sigma=Sigma*M_PI/180;
}
}
#endif // DF_XY_REPORT_HPP