VIPRA Documentation
Loading...
Searching...
No Matches
example_model.hpp
1
2#include "vipra.hpp"
3
4// Create a new module, with it's C++ name and Module type (see Modules page for other types)
5NEW_VIPRA_MODULE(ExampleModel, Model)
6{
7 public:
8 // Give the module a name and set its type
9 VIPRA_MODULE_NAME("Example")
10 VIPRA_MODULE_TYPE(Model)
11
12 // Add in the parameter registration step, this is where we tell VIPRA what parameters the module needs
13 VIPRA_REGISTER_PARAMS(VIPRA_PARAM("radius", _radius))
14
15 // Add in the initialization step, this is run right before the simulation starts
16 VIPRA_MODEL_INIT_STEP { _initialPoints = pedset.all_coords(); }
17
18 // Add in the timestep, this is where the model updates the pedestrians state
19 VIPRA_MODEL_TIMESTEP
20 {
21 for ( size_t i = 0; i < pedset.num_pedestrians(); ++i ) {
22 // Update the pedestrian's position, to make them move in a circle
23 state.positions[i] =
24 VIPRA::f3d{_initialPoints[i][0] + _radius * std::cos(deltaT * timestep),
25 _initialPoints[i][1] + _radius * std::sin(deltaT * timestep)};
26 }
27 }
28
29 private:
30 VIPRA::f_pnt _radius;
31 VIPRA::f3dVec _initialPoints;
32};
Definition f3d.hpp:27