Angle.hpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
39 #ifndef GNSSTK_ANGLE_HPP
40 #define GNSSTK_ANGLE_HPP
41 
42 #include "AngleReduced.hpp"
43 
44 namespace gnsstk
45 {
47 
48 
53  class Angle : public AngleReduced
54  {
55  public:
57  Angle();
58 
63  explicit Angle(double s, double c);
64 
69  explicit Angle(double v, AngleType t)
70  { setValue(v, t); }
71 
76  void setValue(double v, AngleType t);
77 
81  Angle operator-(const Angle& right) const;
82 
85  Angle operator-() const
86  { return Angle(-radians, AngleType::Rad); }
87 
91  Angle operator+(const Angle& right) const;
92 
94  inline double rad() const
95  { return radians; }
96 
98  inline double deg() const
99  { return degrees; }
100 
102  inline double semicirc() const
103  { return semicircles; }
104 
106  inline double tan() const
107  { return tangent; }
108 
111  std::string asString() const;
112 
113  protected:
114  double radians;
115  double degrees;
116  double tangent;
117  double semicircles;
118 
119  private:
120  // Disable a bunch of constructors so unexpected behavior is
121  // avoided in C++. In python, all bets are off,
122  // unfortunately.
123  explicit Angle(int, int);
124  explicit Angle(long, long);
125  explicit Angle(unsigned, unsigned);
126  explicit Angle(unsigned long, unsigned long);
127  }; // class Angle
128 
129 
130  inline std::ostream& operator<<(std::ostream& s, const Angle& a)
131  {
132  s << std::setprecision(20) << "rad:" << a.rad() << ",deg:" << a.deg()
133  << ",semi-circles:" << a.semicirc() << ",sin:" << a.sin() << ",cos:"
134  << a.cos() << ",tan:" << a.tan();
135  return s;
136  }
137 
139 
140 } // namespace gnsstk
141 
142 namespace std
143 {
144  inline double sin(gnsstk::Angle x)
145  { return x.sin(); }
146  inline double cos(gnsstk::Angle x)
147  { return x.cos(); }
148  inline double tan(gnsstk::Angle x)
149  { return x.tan(); }
150 }
151 
152 #endif // GNSSTK_ANGLE_HPP
gnsstk::AngleReduced
Definition: AngleReduced.hpp:60
gnsstk::Angle::operator-
Angle operator-() const
Definition: Angle.hpp:85
gnsstk::Angle::rad
double rad() const
Get the angle in radians.
Definition: Angle.hpp:94
gnsstk::Angle::semicirc
double semicirc() const
Get the angle in semi-circles (aka half-cycles).
Definition: Angle.hpp:102
gnsstk::Angle::radians
double radians
The angle in radians.
Definition: Angle.hpp:114
gnsstk::Angle::tan
double tan() const
Get the tangent of this angle.
Definition: Angle.hpp:106
gnsstk::Angle::asString
std::string asString() const
Definition: Angle.cpp:138
gnsstk::AngleReduced::sin
double sin() const
Get the sine of this angle.
Definition: AngleReduced.hpp:94
gnsstk::Angle::Angle
Angle()
Initialize all data to NaN.
Definition: Angle.cpp:47
gnsstk::Angle::tangent
double tangent
The tangent of the angle.
Definition: Angle.hpp:116
gnsstk::Angle::semicircles
double semicircles
The angle in semi-circles (aka half-cycles).
Definition: Angle.hpp:117
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::Angle
Definition: Angle.hpp:53
std::sin
double sin(gnsstk::Angle x)
Definition: Angle.hpp:144
gnsstk::AngleType::Rad
@ Rad
Value is in radians.
gnsstk::AngleReduced::cos
double cos() const
Get the cosine of this angle.
Definition: AngleReduced.hpp:98
gnsstk::operator<<
std::ostream & operator<<(std::ostream &s, const ObsEpoch &oe) noexcept
Definition: ObsEpochMap.cpp:54
gnsstk::Angle::operator+
Angle operator+(const Angle &right) const
Definition: Angle.cpp:129
gnsstk::Angle::deg
double deg() const
Get the angle in degrees.
Definition: Angle.hpp:98
gnsstk::AngleType
AngleType
Definition: AngleType.hpp:54
std::cos
double cos(gnsstk::Angle x)
Definition: Angle.hpp:146
gnsstk::Angle::degrees
double degrees
The angle in degrees.
Definition: Angle.hpp:115
std::tan
double tan(gnsstk::Angle x)
Definition: Angle.hpp:148
gnsstk::Angle::setValue
void setValue(double v, AngleType t)
Definition: Angle.cpp:68
std
Definition: Angle.hpp:142
gnsstk::Angle::Angle
Angle(double v, AngleType t)
Definition: Angle.hpp:69
AngleReduced.hpp


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:38