23 #include <ns3/double.h>
26 #include "antenna-model.h"
27 #include "cosine-antenna-model.h"
34 NS_OBJECT_ENSURE_REGISTERED (CosineAntennaModel);
38 CosineAntennaModel::GetTypeId ()
40 static TypeId tid = TypeId (
"ns3::CosineAntennaModel")
41 .SetParent<AntennaModel> ()
42 .AddConstructor<CosineAntennaModel> ()
43 .AddAttribute (
"Beamwidth",
44 "The 3dB beamwidth (degrees)",
46 MakeDoubleAccessor (&CosineAntennaModel::SetBeamwidth,
47 &CosineAntennaModel::GetBeamwidth),
48 MakeDoubleChecker<double> (0, 180))
49 .AddAttribute (
"Orientation",
50 "The angle (degrees) that expresses the orientation of the antenna on the x-y plane relative to the x axis",
52 MakeDoubleAccessor (&CosineAntennaModel::SetOrientation,
53 &CosineAntennaModel::GetOrientation),
54 MakeDoubleChecker<double> (-360, 360))
55 .AddAttribute (
"MaxGain",
56 "The gain (dB) at the antenna boresight (the direction of maximum gain)",
58 MakeDoubleAccessor (&CosineAntennaModel::m_maxGain),
59 MakeDoubleChecker<double> ())
65 CosineAntennaModel::SetBeamwidth (
double beamwidthDegrees)
69 m_exponent = -3.0 / (20 * std::log10 (std::cos (m_beamwidthRadians / 4.0)));
74 CosineAntennaModel::GetBeamwidth ()
const
80 CosineAntennaModel::SetOrientation (
double orientationDegrees)
87 CosineAntennaModel::GetOrientation ()
const
97 double phi = a.
phi - m_orientationRadians;
112 double ef = std::pow (std::cos (phi / 2.0),
m_exponent);
120 double gainDb = 20 * std::log10 (ef);
121 NS_LOG_LOGIC (
"gain = " << gainDb <<
" + " << m_maxGain <<
" dB");
122 return gainDb + m_maxGain;
virtual double GetGainDb(Angles a)
#define NS_LOG_FUNCTION(parameters)
double DegreesToRadians(double degrees)
converts degrees to radians
#define NS_LOG_COMPONENT_DEFINE(name)
#define NS_LOG_LOGIC(msg)
double RadiansToDegrees(double radians)
converts radians to degrees