A Discrete-Event Network Simulator
API
ns3::Angles Class Reference

Class holding the azimuth and inclination angles of spherical coordinates. More...

#include "angles.h"

Public Member Functions

 Angles (double azimuth, double inclination)
 This constructor allows to specify azimuth and inclination. More...
 
 Angles (Vector v)
 This constructor will initialize azimuth and inclination by converting the given 3D vector from cartesian coordinates to spherical coordinates Note: azimuth and inclination angles for a zero-length vector are not defined and are thus initialized to NAN. More...
 
 Angles (Vector v, Vector o)
 This constructor initializes an Angles instance with the angles of the spherical coordinates of point v respect to point o. More...
 
double GetAzimuth (void) const
 Getter for azimuth angle. More...
 
double GetInclination (void) const
 Getter for inclination angle. More...
 
void SetAzimuth (double azimuth)
 Setter for azimuth angle. More...
 
void SetInclination (double inclination)
 Setter for inclination angle. More...
 

Static Public Attributes

static bool m_printDeg = false
 flag for printing in radians or degrees units More...
 

Private Member Functions

 Angles ()
 Default constructor is disabled. More...
 
void CheckIfValid (void) const
 Check if Angle is valid or not Warns the user if the Angle is undefined (non-finite azimuth or inclination), throws an assert if the inclination angle is invalid (not in [0, M_PI]) More...
 
void NormalizeAngles (void)
 Normalize the angle azimuth angle range between in [-M_PI, M_PI) while checking if the angle is valid, i.e., finite and within the bounds. More...
 

Private Attributes

double m_azimuth
 the azimuth angle in radians More...
 
double m_inclination
 the inclination angle in radians More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Angles &a)
 
std::istream & operator>> (std::istream &is, Angles &a)
 

Detailed Description

Class holding the azimuth and inclination angles of spherical coordinates.

The notation is the one used in "Antenna Theory - Analysis and Design", C.A. Balanis, Wiley, 2nd Ed., section 2.2 "Radiation pattern". This notation corresponds to the standard spherical coordinates, with azimuth measured counterclockwise in the x-y plane off the x-axis, and inclination measured off the z-axis. Azimuth is consistently normalized to be in [-M_PI, M_PI).

     ^
   z | 
     |_ inclination
     | \
     | /|
     |/ |   y
     +-------->
    /  \|
   /___/
x /  azimuth
 |/

Definition at line 118 of file angles.h.

Constructor & Destructor Documentation

◆ Angles() [1/4]

ns3::Angles::Angles ( double  azimuth,
double  inclination 
)

This constructor allows to specify azimuth and inclination.

Inclination must be in [0, M_PI], while azimuth is automatically notmalized in [-M_PI, M_PI)

Parameters
azimuththe azimuth angle in radians
inclinationthe inclination angle in radians

Definition at line 177 of file angles.cc.

References NormalizeAngles().

+ Here is the call graph for this function:

◆ Angles() [2/4]

ns3::Angles::Angles ( Vector  v)

This constructor will initialize azimuth and inclination by converting the given 3D vector from cartesian coordinates to spherical coordinates Note: azimuth and inclination angles for a zero-length vector are not defined and are thus initialized to NAN.

Parameters
vthe 3D vector in cartesian coordinates

Definition at line 185 of file angles.cc.

References m_azimuth, m_inclination, and NormalizeAngles().

+ Here is the call graph for this function:

◆ Angles() [3/4]

ns3::Angles::Angles ( Vector  v,
Vector  o 
)

This constructor initializes an Angles instance with the angles of the spherical coordinates of point v respect to point o.

Parameters
vthe point (in cartesian coordinates) for which the angles are determined
othe origin (in cartesian coordinates) of the spherical coordinate system

Definition at line 199 of file angles.cc.

◆ Angles() [4/4]

ns3::Angles::Angles ( )
private

Default constructor is disabled.

Definition at line 172 of file angles.cc.

Member Function Documentation

◆ CheckIfValid()

void ns3::Angles::CheckIfValid ( void  ) const
private

Check if Angle is valid or not Warns the user if the Angle is undefined (non-finite azimuth or inclination), throws an assert if the inclination angle is invalid (not in [0, M_PI])

Definition at line 251 of file angles.cc.

References m_azimuth, m_inclination, NS_ASSERT_MSG, and NS_LOG_WARN.

Referenced by NormalizeAngles().

+ Here is the caller graph for this function:

◆ GetAzimuth()

◆ GetInclination()

◆ NormalizeAngles()

void ns3::Angles::NormalizeAngles ( void  )
private

Normalize the angle azimuth angle range between in [-M_PI, M_PI) while checking if the angle is valid, i.e., finite and within the bounds.

Note: while an arbitrary value for the azimuth angle is valid and can be wrapped in [-M_PI, M_PI), an inclination angle outside the [0, M_PI] range can be ambiguos and is thus not valid.

Definition at line 236 of file angles.cc.

References CheckIfValid(), m_azimuth, and ns3::WrapToPi().

Referenced by Angles(), SetAzimuth(), and SetInclination().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetAzimuth()

void ns3::Angles::SetAzimuth ( double  azimuth)

Setter for azimuth angle.

Parameters
azimuthangle in radians

Definition at line 206 of file angles.cc.

References m_azimuth, and NormalizeAngles().

Referenced by ns3::CosineAntennaModel::GetGainDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetInclination()

void ns3::Angles::SetInclination ( double  inclination)

Setter for inclination angle.

Parameters
inclinationangle in radians. Must be in [0, M_PI]

Definition at line 214 of file angles.cc.

References m_inclination, and NormalizeAngles().

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Angles a 
)
friend

Definition at line 137 of file angles.cc.

◆ operator>>

std::istream& operator>> ( std::istream &  is,
Angles a 
)
friend

Definition at line 160 of file angles.cc.

Member Data Documentation

◆ m_azimuth

double ns3::Angles::m_azimuth
private

the azimuth angle in radians

Definition at line 211 of file angles.h.

Referenced by Angles(), CheckIfValid(), GetAzimuth(), NormalizeAngles(), ns3::operator<<(), ns3::operator>>(), and SetAzimuth().

◆ m_inclination

double ns3::Angles::m_inclination
private

the inclination angle in radians

Definition at line 212 of file angles.h.

Referenced by Angles(), CheckIfValid(), GetInclination(), ns3::operator<<(), ns3::operator>>(), and SetInclination().

◆ m_printDeg

bool ns3::Angles::m_printDeg = false
static

flag for printing in radians or degrees units

Definition at line 184 of file angles.h.

Referenced by ns3::operator<<().


The documentation for this class was generated from the following files: