Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Attributes | List of all members
Menge::Agents::HexLatticeGenerator Class Reference

Definition of an agent generator class which produces agents based on the positions of intersections on a hexagonal lattice bounded by a rectangle. More...

#include <HexLatticeGenerator.h>

Inheritance diagram for Menge::Agents::HexLatticeGenerator:
Menge::Agents::AgentGenerator Menge::Element

Public Types

enum  AnchorAlignEnum { CENTER, LEFT_CORNER, RIGHT_CORNER }
 Enumeration specifying arrangement relative to the anchor point. More...
 
enum  LatticeRowEnum { ROW_X, ROW_Y }
 Enumeration indicating which axis the regular rows occur. More...
 

Public Member Functions

 HexLatticeGenerator ()
 Constructor.
 
virtual size_t agentCount ()
 Reports the number of agents created. More...
 
virtual Vector2 agentPos (size_t i)
 Get the position of the ith agent. More...
 
void set (const Vector2 &anchor, AnchorAlignEnum align, LatticeRowEnum dir, float width, float density, size_t tgtPopulation, float angle)
 Sets the properties of the generator. More...
 
void setRotationDeg (float angle)
 Sets the lattice rotation.
 
- Public Member Functions inherited from Menge::Agents::AgentGenerator
 AgentGenerator ()
 Constructor.
 
void setNoiseGenerator (Math::FloatGenerator *gen)
 Sets the Generators noise generation. More...
 
Vector2 addNoise (const Vector2 &pos)
 Perturbs the given point according to the given noise generator. More...
 
- Public Member Functions inherited from Menge::Element
void destroy ()
 This supplants the destructor. More...
 
virtual BFSM::TaskgetTask ()
 Return an optional task associated with this element. More...
 
virtual SceneGraph::GLNodegetSGNode ()
 Returns an optional visualization element associated with the element. More...
 

Protected Attributes

Vector2 _anchor
 The anchor point of the lattice. One agent will be positioned at this world coordainte.
 
LatticeRowEnum _rowDir
 The direction of the row layout.
 
float _cosRot
 The cosine of the amount the lattice is rotated around its anchor point. positive rotation values are counter-clockwise rotation.
 
float _sinRot
 The sine of the amount the lattice is rotated around its anchor point. positive rotation values are counter-clockwise rotation.
 
size_t _totalPop
 The actual number of agents to create based on run-time parameters. This value is only valid AFTER finalize has been called.
 
float _rowDist
 The distance between rows for the given target density.
 
float _nbrDist
 The distance between neighbors in a single row for the given target density.
 
size_t _rowPop
 The population of the major row (interpreted differently depending on lattice row direction.
 
size_t _rowCount
 The number of rows to create.
 
- Protected Attributes inherited from Menge::Agents::AgentGenerator
Math::FloatGenerator_disp
 The generator for displacement amount (defaults to zero).
 
Math::FloatGenerator_dir
 The generator for angular displacement.
 

Additional Inherited Members

- Protected Member Functions inherited from Menge::Agents::AgentGenerator
virtual ~AgentGenerator ()
 Virtual destructor.
 

Detailed Description

Definition of an agent generator class which produces agents based on the positions of intersections on a hexagonal lattice bounded by a rectangle.

Circles can be maximally packed into a hexagonal lattice. In this case, an open rectangular region is defined (relative to an anchor point) and agents are placed in a hexagonal lattice, bounded by the rectangular region on three sides.

The rectangular region is defined in "local" space. In its own local space, the rectangular region lies on the x-axis and extends into the positive y-direction. The "front" of the region lies on the x-axis and the left and right sides extend into the positive y-direction. The alignment of the rectangular region relative to the anchor point depends on the AnchorAlignEnum value.

The hexagonal grid lattice size is based on the target average density. The lattice points are placed to achieve that average density. The lattice will either be aligned with the x-axis or the y-axis, depending on the LatticeRowEnum value.

Member Enumeration Documentation

Enumeration specifying arrangement relative to the anchor point.

Enumerator
CENTER 

The front boundary is centered on the anchor.

LEFT_CORNER 

The front boundary's "left" corner is on the anchor.

RIGHT_CORNER 

The front boundary's "right" corner is on the anchor.

Enumeration indicating which axis the regular rows occur.

Enumerator
ROW_X 

The rows run parallel with the local x-axis.

ROW_Y 

The rows run parallel with the local y-axis.

Member Function Documentation

virtual size_t Menge::Agents::HexLatticeGenerator::agentCount ( )
inlinevirtual

Reports the number of agents created.

Returns
The number of agents this generator creates.

Implements Menge::Agents::AgentGenerator.

Vector2 Menge::Agents::HexLatticeGenerator::agentPos ( size_t  i)
virtual

Get the position of the ith agent.

Parameters
iThe index of the requested agent.
Returns
The 2D position of the agent based on the generator's parameters.
Exceptions
AgentGeneratorExceptionif the index, i, is invalid.

Implements Menge::Agents::AgentGenerator.

void Menge::Agents::HexLatticeGenerator::set ( const Vector2 anchor,
AnchorAlignEnum  align,
LatticeRowEnum  dir,
float  width,
float  density,
size_t  tgtPopulation,
float  angle 
)

Sets the properties of the generator.

Parameters
anchorThe anchor position of the lattice.
alignThe target alignment.
dirThe desired row direction.
widthThe width of the bounding region
densityThe target density (agent /m^2).
tgtPopulationThe target population (agents).
angleThe rotation angle (in degrees).

The documentation for this class was generated from the following files: