Utopia 2
Framework for studying models of complex & adaptive systems.
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Utopia::Models::SimpleFlocking::AgentState Class Reference

An agent's state. More...

#include <state.hh>

Public Member Functions

 AgentState ()
 Default constructor with zero-initialized members.
 
template<typename RNGType >
 AgentState (const Config &cfg, const std::shared_ptr< RNGType > &rng)
 Constructor with config node and RNG.
 
auto get_speed () const
 Returns the current speed of this agent.
 
auto get_orientation () const
 Returns the current orientation in radians, [-π, +π)
 
const autoget_displacement () const
 The current value of the displacement vector.
 
auto set_speed (double new_speed)
 Sets the speed and subsequently updates the displacement vector.
 
auto set_orientation (double new_orientation)
 Sets the orientation and subsequently updates the displacement vector.
 

Protected Member Functions

void update_displacement ()
 Updates the displacement vector using current speed and orientation.
 

Private Attributes

double speed
 Agent speed.
 
double orientation
 Orientation in radians, [-π, +π)
 
SpaceVecType< 2 > displacement
 The current displacement vector, updated upon any changes.
 

Detailed Description

An agent's state.

Constructor & Destructor Documentation

◆ AgentState() [1/2]

Utopia::Models::SimpleFlocking::AgentState::AgentState ( )
inline

Default constructor with zero-initialized members.

31 :
32 speed(0.)
33 , orientation(0.)
34 , displacement({0., 0.})
35 {}
SpaceVecType< 2 > displacement
The current displacement vector, updated upon any changes.
Definition state.hh:26
double orientation
Orientation in radians, [-π, +π)
Definition state.hh:23
double speed
Agent speed.
Definition state.hh:17

◆ AgentState() [2/2]

template<typename RNGType >
Utopia::Models::SimpleFlocking::AgentState::AgentState ( const Config cfg,
const std::shared_ptr< RNGType > &  rng 
)
inline

Constructor with config node and RNG.

40 :
41 speed(get_as<double>("speed", cfg, 0.))
43 , displacement({0., 0.})
44 {
46 }
void update_displacement()
Updates the displacement vector using current speed and orientation.
Definition state.hh:88
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213
T random_angle(const std::shared_ptr< RNG > &rng)
Returns a uniformly random angle value in [-π, +π)
Definition utils.hh:26

Member Function Documentation

◆ get_displacement()

const auto & Utopia::Models::SimpleFlocking::AgentState::get_displacement ( ) const
inline

The current value of the displacement vector.

64 {
65 return displacement;
66 }

◆ get_orientation()

auto Utopia::Models::SimpleFlocking::AgentState::get_orientation ( ) const
inline

Returns the current orientation in radians, [-π, +π)

An orientation value of zero points in positive x direction while a value of ±π/2 points in ±y direction.

59 {
60 return orientation;
61 }

◆ get_speed()

auto Utopia::Models::SimpleFlocking::AgentState::get_speed ( ) const
inline

Returns the current speed of this agent.

51 {
52 return speed;
53 }

◆ set_orientation()

auto Utopia::Models::SimpleFlocking::AgentState::set_orientation ( double  new_orientation)
inline

Sets the orientation and subsequently updates the displacement vector.

This also makes sure the new orientation is within a valid range

79 {
82 }
T constrain_angle(T angle)
Constrains an angle value to interval [-π, +π)
Definition utils.hh:32

◆ set_speed()

auto Utopia::Models::SimpleFlocking::AgentState::set_speed ( double  new_speed)
inline

Sets the speed and subsequently updates the displacement vector.

71 {
74 }

◆ update_displacement()

void Utopia::Models::SimpleFlocking::AgentState::update_displacement ( )
inlineprotected

Updates the displacement vector using current speed and orientation.

88 {
89 displacement[0] = speed * std::cos(orientation);
90 displacement[1] = speed * std::sin(orientation);
91 }

Member Data Documentation

◆ displacement

SpaceVecType<2> Utopia::Models::SimpleFlocking::AgentState::displacement
private

The current displacement vector, updated upon any changes.

◆ orientation

double Utopia::Models::SimpleFlocking::AgentState::orientation
private

Orientation in radians, [-π, +π)

Orientation zero points in positive x direction while ±π/2 points in ±y direction.

◆ speed

double Utopia::Models::SimpleFlocking::AgentState::speed
private

Agent speed.


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