mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 01:53:58 +02:00
Add polar position allocator
This commit is contained in:
parent
70c70a19ce
commit
ab7c9881f6
7 changed files with 147 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
|
||||
#ifndef LEO_CIRCULAR_ORBIT_HELPER_H
|
||||
#define LEO_CIRCULAR_ORBIT_HELPER_H
|
||||
#ifndef LEO_CIRCULAR_ORBIT_POSITION_ALLOCATOR_H
|
||||
#define LEO_CIRCULAR_ORBIT_POSITION_ALLOCATOR_H
|
||||
|
||||
#include "ns3/position-allocator.h"
|
||||
|
||||
|
|
88
model/leo-polar-position-allocator.cc
Normal file
88
model/leo-polar-position-allocator.cc
Normal file
|
@ -0,0 +1,88 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
|
||||
#include "math.h"
|
||||
|
||||
#include "ns3/double.h"
|
||||
|
||||
#include "leo-polar-position-allocator.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (LeoPolarPositionAllocator);
|
||||
|
||||
LeoPolarPositionAllocator::LeoPolarPositionAllocator ()
|
||||
: m_latStart (0), m_lonStart (0), m_latEnd (0), m_lonEnd (0), m_step (5), m_lat (-1000.0), m_lon (-1000.0)
|
||||
{}
|
||||
|
||||
LeoPolarPositionAllocator::~LeoPolarPositionAllocator ()
|
||||
{}
|
||||
|
||||
TypeId
|
||||
LeoPolarPositionAllocator::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::LeoPolarPositionAllocator")
|
||||
.SetParent<PositionAllocator> ()
|
||||
.SetGroupName ("Leo")
|
||||
.AddConstructor<LeoPolarPositionAllocator> ()
|
||||
.AddAttribute ("LatStart",
|
||||
"Start at this latitude",
|
||||
DoubleValue (-90),
|
||||
MakeDoubleAccessor (&LeoPolarPositionAllocator::m_latStart),
|
||||
MakeDoubleChecker<double> ())
|
||||
.AddAttribute ("LatStop",
|
||||
"Stop at this longitude",
|
||||
DoubleValue (90),
|
||||
MakeDoubleAccessor (&LeoPolarPositionAllocator::m_latEnd),
|
||||
MakeDoubleChecker<double> ())
|
||||
.AddAttribute ("LongStart",
|
||||
"Start at this longitude",
|
||||
DoubleValue (-180),
|
||||
MakeDoubleAccessor (&LeoPolarPositionAllocator::m_lonStart),
|
||||
MakeDoubleChecker<double> ())
|
||||
.AddAttribute ("LongStop",
|
||||
"Stop at this longitude",
|
||||
DoubleValue (180),
|
||||
MakeDoubleAccessor (&LeoPolarPositionAllocator::m_lonEnd),
|
||||
MakeDoubleChecker<double> ())
|
||||
.AddAttribute ("Step",
|
||||
"The degrees inbetween neighboring locations",
|
||||
DoubleValue (5),
|
||||
MakeDoubleAccessor (&LeoPolarPositionAllocator::m_step),
|
||||
MakeDoubleChecker<double> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
int64_t
|
||||
LeoPolarPositionAllocator::AssignStreams (int64_t stream)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
Vector
|
||||
LeoPolarPositionAllocator::GetNext () const
|
||||
{
|
||||
m_lat = std::max (m_latStart, m_lat);
|
||||
m_lon = std::max (m_lonStart, m_lon);
|
||||
|
||||
double lat = m_lat * (M_PI / 90);
|
||||
double lon = m_lon * (M_PI / 180);
|
||||
Vector3D next = Vector3D (LEO_GND_RAD_EARTH * sin (lat) * cos (lon),
|
||||
LEO_GND_RAD_EARTH * sin (lat) * sin (lon),
|
||||
LEO_GND_RAD_EARTH * cos (lat));
|
||||
|
||||
m_lat = m_lat + m_step;
|
||||
if (m_lat > m_latEnd)
|
||||
{
|
||||
m_lat = m_latStart;
|
||||
m_lon += m_step;
|
||||
if (m_lon > m_lonEnd)
|
||||
{
|
||||
m_lon = m_lonStart;
|
||||
}
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
};
|
45
model/leo-polar-position-allocator.h
Normal file
45
model/leo-polar-position-allocator.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
|
||||
#ifndef LEO_POLAR_POSITION_ALLOCATOR_H
|
||||
#define LEO_POLAR_POSITION_ALLOCATOR_H
|
||||
|
||||
#include "ns3/position-allocator.h"
|
||||
|
||||
#define LEO_GND_RAD_EARTH 6.371e6
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \brief Allocate pairs of latitude and longitude.
|
||||
*/
|
||||
class LeoPolarPositionAllocator : public PositionAllocator
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Register this type with the TypeId system.
|
||||
* \return the object TypeId
|
||||
*/
|
||||
static TypeId GetTypeId ();
|
||||
|
||||
LeoPolarPositionAllocator ();
|
||||
virtual ~LeoPolarPositionAllocator ();
|
||||
|
||||
virtual Vector GetNext (void) const;
|
||||
virtual int64_t AssignStreams (int64_t stream);
|
||||
|
||||
private:
|
||||
double m_latStart;
|
||||
double m_lonStart;
|
||||
|
||||
double m_latEnd;
|
||||
double m_lonEnd;
|
||||
|
||||
double m_step;
|
||||
|
||||
mutable double m_lat;
|
||||
mutable double m_lon;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue