A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
parabolic-antenna-model.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 CTTC
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 */
8
10
11#include "antenna-model.h"
12
13#include <ns3/double.h>
14#include <ns3/log.h>
15
16#include <cmath>
17
18namespace ns3
19{
20
21NS_LOG_COMPONENT_DEFINE("ParabolicAntennaModel");
22
23NS_OBJECT_ENSURE_REGISTERED(ParabolicAntennaModel);
24
25TypeId
27{
28 static TypeId tid =
29 TypeId("ns3::ParabolicAntennaModel")
31 .SetGroupName("Antenna")
32 .AddConstructor<ParabolicAntennaModel>()
33 .AddAttribute("Beamwidth",
34 "The 3dB beamwidth (degrees)",
35 DoubleValue(60),
39 .AddAttribute("Orientation",
40 "The angle (degrees) that expresses the orientation of the antenna on "
41 "the x-y plane relative to the x axis",
42 DoubleValue(0.0),
46 .AddAttribute("MaxAttenuation",
47 "The maximum attenuation (dB) of the antenna radiation pattern.",
48 DoubleValue(20.0),
51 return tid;
52}
53
54void
56{
57 NS_LOG_FUNCTION(this << beamwidthDegrees);
58 m_beamwidthRadians = DegreesToRadians(beamwidthDegrees);
59}
60
61double
66
67void
68ParabolicAntennaModel::SetOrientation(double orientationDegrees)
69{
70 NS_LOG_FUNCTION(this << orientationDegrees);
71 m_orientationRadians = DegreesToRadians(orientationDegrees);
72}
73
74double
79
80double
82{
83 NS_LOG_FUNCTION(this << a);
84 // azimuth angle w.r.t. the reference system of the antenna
85 double phi = a.GetAzimuth() - m_orientationRadians;
86
87 // make sure phi is in (-pi, pi]
88 while (phi <= -M_PI)
89 {
90 phi += M_PI + M_PI;
91 }
92 while (phi > M_PI)
93 {
94 phi -= M_PI + M_PI;
95 }
96
97 NS_LOG_LOGIC("phi = " << phi);
98
99 double gainDb = -std::min(12 * pow(phi / m_beamwidthRadians, 2), m_maxAttenuation);
100
101 NS_LOG_LOGIC("gain = " << gainDb);
102 return gainDb;
103}
104
105} // namespace ns3
Class holding the azimuth and inclination angles of spherical coordinates.
Definition angles.h:107
double GetAzimuth() const
Getter for azimuth angle.
Definition angles.cc:230
interface for antenna radiation pattern models
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Antenna model based on a parabolic approximation of the main lobe radiation pattern.
static TypeId GetTypeId()
Get the type ID.
void SetBeamwidth(double beamwidthDegrees)
Set the Beam width.
double GetGainDb(Angles a) override
this method is expected to be re-implemented by each antenna model
double GetBeamwidth() const
Get the Beam width.
double m_orientationRadians
Antenna orientation in radians.
double GetOrientation() const
Get the antenna orientation.
double m_maxAttenuation
Max attenuation.
void SetOrientation(double orientationDegrees)
Set the antenna orientation.
double m_beamwidthRadians
Beam width in radians.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
double DegreesToRadians(double degrees)
converts degrees to radians
Definition angles.cc:28
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32
double RadiansToDegrees(double radians)
converts radians to degrees
Definition angles.cc:34