66 lines
2.3 KiB
C++
66 lines
2.3 KiB
C++
#pragma once
|
|
#include "constants.hpp"
|
|
#include "vector2d.hpp"
|
|
|
|
// Needed for visual simulation, in order to distinguish two groups of pedestrians:
|
|
// - White pedestrians move from left to right
|
|
// - Black pedestrians move from right to left
|
|
enum Color { WHITE, BLACK};
|
|
|
|
struct Pedestrian {
|
|
|
|
Color color;
|
|
|
|
// $\vec{v}_{\alpha}(t)$
|
|
Vector2d curr_vel; // v_alpha (actual, ≤ v_max)
|
|
|
|
// $\vec{w}_{\alpha}$
|
|
Vector2d w; // w_alpha (preferred, integrates force)
|
|
|
|
// $\vec{r}_\alpha(t)$
|
|
Vector2d curr_pos;
|
|
|
|
// $\vec{e}_{\alpha}(t)$
|
|
Vector2d e; // desired direction vector
|
|
|
|
// $v_{\alpha}^{max} = 1.3 v^{0}_{\alpha}$
|
|
double v_max;
|
|
|
|
// $v_\alpha^0$
|
|
double desired_v0;
|
|
|
|
// $\vec{r}^0_\alpha$
|
|
Vector2d destination;
|
|
// $s_\beta^2 = (v_\beta \Delta t)^2$
|
|
double s_b_sq;
|
|
// $s_\beta \vec{e}_\beta$
|
|
Vector2d s_b_e;
|
|
|
|
// Default constructor: initializes a pedestrian with color WHITE and all vector/scalar fields set to zero.
|
|
Pedestrian() : color(WHITE), curr_vel(0.0, 0.0), w(0.0, 0.0), curr_pos(0.0, 0.0), e(0.0, 0.0), v_max(0.0), desired_v0(0.0), destination(0.0, 0.0), s_b_sq(0.0), s_b_e(0.0, 0.0) {}
|
|
|
|
// Constructs a pedestrian with the given initial state and precomputes the
|
|
// quantities used in the pedestrian-pedestrian repulsion term.
|
|
//
|
|
// The preferred velocity w is initialized to the current velocity c_v. The
|
|
// cached quantities s_b_sq and s_b_e correspond to the predicted step of this
|
|
// pedestrian over $\Delta t$:
|
|
//
|
|
// s_b = ||c_v|| * dt
|
|
// s_b_sq = s_b^2
|
|
// s_b_e = e * s_b
|
|
//
|
|
// These values are used when another pedestrian computes the elliptical
|
|
// interaction term involving this pedestrian.
|
|
//
|
|
// @param clr The display/color category of the pedestrian.
|
|
// @param c_v The initial current velocity.
|
|
// @param c_p The initial current position.
|
|
// @param e The initial desired direction of motion.
|
|
// @param v_max The maximum speed that the pedestrian can reach.
|
|
// @param desired_v0 The desired walking speed.
|
|
// @param d The pedestrian's target destination point.
|
|
//
|
|
Pedestrian(Color clr, Vector2d c_v, Vector2d c_p, Vector2d e, double v_max, double desired_v0, Vector2d d) : color(clr), curr_vel(c_v), w(c_v), curr_pos(c_p), e(e), v_max(v_max), desired_v0(desired_v0), destination(d), s_b_sq(c_v.dot(c_v) * delta_t_sq), s_b_e(e * c_v.norm() * delta_t) {}
|
|
};
|