A Discrete-Event Network Simulator
API
angles.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011, 2012 CTTC
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Nicola Baldo <nbaldo@cttc.es>
19  */
20 
21 #ifndef ANGLES_H
22 #define ANGLES_H
23 
24 
25 #include <ns3/vector.h>
26 #include <vector>
27 
28 namespace ns3 {
29 
30 
37 double DegreesToRadians (double degrees);
38 
45 std::vector<double> DegreesToRadians (const std::vector<double> &degrees);
46 
53 double RadiansToDegrees (double radians);
54 
61 std::vector<double> RadiansToDegrees (const std::vector<double> &radians);
62 
69 double WrapTo360 (double a);
70 
77 double WrapTo180 (double a);
78 
85 double WrapTo2Pi (double a);
86 
93 double WrapToPi (double a);
94 
118 class Angles
119 {
120 public:
129  Angles (double azimuth, double inclination);
130 
140  Angles (Vector v);
141 
150  Angles (Vector v, Vector o);
151 
157  void SetAzimuth (double azimuth);
158 
164  void SetInclination (double inclination);
165 
171  double GetAzimuth (void) const;
172 
178  double GetInclination (void) const;
179 
180  // friend methods
188  friend std::ostream& operator<< (std::ostream& os, const Angles& a);
196  friend std::istream& operator>> (std::istream& is, Angles& a);
197 
198  static bool m_printDeg;
199 
200 private:
204  Angles ();
205 
215  void NormalizeAngles (void);
216 
222  void CheckIfValid (void) const;
223 
224 
225  double m_azimuth;
226  double m_inclination;
227 };
228 
229 
230 } // namespace ns3
231 
232 #endif // ANGLES_H
Class holding the azimuth and inclination angles of spherical coordinates.
Definition: angles.h:119
friend std::ostream & operator<<(std::ostream &os, const Angles &a)
Stream insertion operator.
Definition: angles.cc:139
double GetInclination(void) const
Getter for inclination angle.
Definition: angles.cc:231
double m_inclination
the inclination angle in radians
Definition: angles.h:226
void NormalizeAngles(void)
Normalize the angle azimuth angle range between in [-M_PI, M_PI) while checking if the angle is valid...
Definition: angles.cc:238
void CheckIfValid(void) const
Check if Angle is valid or not Warns the user if the Angle is undefined (non-finite azimuth or inclin...
Definition: angles.cc:253
double GetAzimuth(void) const
Getter for azimuth angle.
Definition: angles.cc:224
static bool m_printDeg
flag for printing in radians or degrees units
Definition: angles.h:198
void SetAzimuth(double azimuth)
Setter for azimuth angle.
Definition: angles.cc:208
Angles()
Default constructor is disabled.
Definition: angles.cc:174
void SetInclination(double inclination)
Setter for inclination angle.
Definition: angles.cc:216
double m_azimuth
the azimuth angle in radians
Definition: angles.h:225
friend std::istream & operator>>(std::istream &is, Angles &a)
Stream extraction operator.
Definition: angles.cc:162
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:124
double WrapTo180(double a)
Wrap angle in [-180, 180)
Definition: angles.cc:95
double WrapTo360(double a)
Wrap angle in [0, 360)
Definition: angles.cc:81
double DegreesToRadians(double degrees)
converts degrees to radians
Definition: angles.cc:40
double WrapTo2Pi(double a)
Wrap angle in [0, 2*M_PI)
Definition: angles.cc:110
double RadiansToDegrees(double radians)
converts radians to degrees
Definition: angles.cc:47