22 static TypeId tid =
TypeId(
"ns3::HexGridPositionAllocator")
24 .AddConstructor<HexGridPositionAllocator>()
26 .AddAttribute(
"Radius",
27 "The radius of a single hexagon",
44 for (
int i = 0; i < 20; i++)
63 for (
int i = 0; i < 20; i++)
112 std::vector<Vector> copy = positions;
115 for (
auto it = positions.begin(); it != positions.end(); it++)
118 Vector currentPosition = *it;
124 for (
double angle = 0; angle < 2 *
pi; angle +=
pi / 3)
126 newPosition = Vector(currentPosition.x + 2 *
m_radius * std::sin(angle),
127 currentPosition.y + 2 *
m_radius * std::cos(angle),
133 for (
auto it = copy.begin(); it != copy.end(); it++)
146 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.
Ptr< const AttributeChecker > MakeDoubleChecker()
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)