20#include "ns3/double.h"
33 static TypeId tid =
TypeId(
"ns3::HexGridPositionAllocator")
35 .AddConstructor<HexGridPositionAllocator>()
37 .AddAttribute(
"Radius",
38 "The radius of a single hexagon",
41 MakeDoubleChecker<double>());
55 for (
int i = 0; i < 20; i++)
74 for (
int i = 0; i < 20; i++)
106 Vector position = *
m_next;
123 std::vector<Vector> copy = positions;
126 for (
auto it = positions.begin(); it != positions.end(); it++)
129 Vector currentPosition = *it;
135 for (
double angle = 0; angle < 2 *
pi; angle +=
pi / 3)
137 newPosition = Vector(currentPosition.x + 2 *
m_radius * std::sin(angle),
138 currentPosition.y + 2 *
m_radius * std::cos(angle),
144 for (
auto it = copy.begin(); it != copy.end(); it++)
157 copy.push_back(newPosition);
This class can be used to hold variables of floating point type such as 'double' or 'float'.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
void SetRadius(double radius)
Set the radius of the circle inscribed in the hexagonal tiles.
static TypeId GetTypeId()
Register this type.
std::vector< Vector > AddRing(std::vector< Vector > positions)
This method adds to the given list of positions an outer ring of positions.
double GetRadius() const
Get the radius of the circle inscribed in the hexagonal tiles.
HexGridPositionAllocator()
Default constructor.
static const double pi
Pi.
double m_radius
The radius of a cell (defined as the half the distance between two adjacent nodes,...
Vector GetNext() const override
~HexGridPositionAllocator() override
Destructor.
std::vector< Vector > m_positions
The current list of positions.
std::vector< Vector >::const_iterator m_next
The iterator pointing to the next position to return.
Allocate a set of positions.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)