A Discrete-Event Network Simulator
API
angles.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, 2012 CTTC
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Nicola Baldo <nbaldo@cttc.es>
18  */
19 
20 #ifndef ANGLES_H
21 #define ANGLES_H
22 
23 #include <ns3/vector.h>
24 
25 #include <vector>
26 
27 namespace ns3
28 {
29 
36 double DegreesToRadians(double degrees);
37 
44 std::vector<double> DegreesToRadians(const std::vector<double>& degrees);
45 
52 double RadiansToDegrees(double radians);
53 
60 std::vector<double> RadiansToDegrees(const std::vector<double>& radians);
61 
68 double WrapTo360(double a);
69 
76 double WrapTo180(double a);
77 
84 double WrapTo2Pi(double a);
85 
92 double WrapToPi(double a);
93 
117 class Angles
118 {
119  public:
128  Angles(double azimuth, double inclination);
129 
139  Angles(Vector v);
140 
149  Angles(Vector v, Vector o);
150 
156  void SetAzimuth(double azimuth);
157 
163  void SetInclination(double inclination);
164 
170  double GetAzimuth() const;
171 
177  double GetInclination() const;
178 
179  // friend methods
187  friend std::ostream& operator<<(std::ostream& os, const Angles& a);
195  friend std::istream& operator>>(std::istream& is, Angles& a);
196 
197  static bool m_printDeg;
198 
199  private:
203  Angles();
204 
214  void NormalizeAngles();
215 
221  void CheckIfValid() const;
222 
223  double m_azimuth;
224  double m_inclination;
225 };
226 
227 } // namespace ns3
228 
229 #endif // ANGLES_H
Class holding the azimuth and inclination angles of spherical coordinates.
Definition: angles.h:118
friend std::ostream & operator<<(std::ostream &os, const Angles &a)
Stream insertion operator.
Definition: angles.cc:159
void NormalizeAngles()
Normalize the angle azimuth angle range between in [-M_PI, M_PI) while checking if the angle is valid...
Definition: angles.cc:252
double m_inclination
the inclination angle in radians
Definition: angles.h:224
double GetInclination() const
Getter for inclination angle.
Definition: angles.cc:246
static bool m_printDeg
flag for printing in radians or degrees units
Definition: angles.h:197
void SetAzimuth(double azimuth)
Setter for azimuth angle.
Definition: angles.cc:226
Angles()
Default constructor is disabled.
Definition: angles.cc:194
void SetInclination(double inclination)
Setter for inclination angle.
Definition: angles.cc:233
double m_azimuth
the azimuth angle in radians
Definition: angles.h:223
double GetAzimuth() const
Getter for azimuth angle.
Definition: angles.cc:240
void CheckIfValid() const
Check if Angle is valid or not Warns the user if the Angle is undefined (non-finite azimuth or inclin...
Definition: angles.cc:266
friend std::istream & operator>>(std::istream &is, Angles &a)
Stream extraction operator.
Definition: angles.cc:183
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double WrapToPi(double a)
Wrap angle in [-M_PI, M_PI)
Definition: angles.cc:138
double WrapTo180(double a)
Wrap angle in [-180, 180)
Definition: angles.cc:96
double WrapTo360(double a)
Wrap angle in [0, 360)
Definition: angles.cc:75
double DegreesToRadians(double degrees)
converts degrees to radians
Definition: angles.cc:39
double WrapTo2Pi(double a)
Wrap angle in [0, 2*M_PI)
Definition: angles.cc:117
double RadiansToDegrees(double radians)
converts radians to degrees
Definition: angles.cc:45