Sidewalk, Cell, get_direction(), compute_acceleration()

This commit is contained in:
smail alijagic
2026-03-19 23:34:22 +01:00
parent 980bb5635e
commit df482ec7aa
2 changed files with 156 additions and 3 deletions
+62 -3
View File
@@ -26,6 +26,16 @@ struct Vector2d {
}
};
struct Sidewalk{
int row, col;
double length, width;
Sidewalk(int r, int c, double l, double w) : row(r), col(c), length(l), width(w) {}
};
struct Cell{
// TODO: cell stores information such as next neighbor
};
// Numer of pedestrians
// $n_p$
const int n_p = 100;
@@ -38,9 +48,58 @@ const int n_iter = 100;
// $\tau$
const double tau = 0.12345;
void compute_acceleration_term(Vector2d *F_i) {}
void compute_repulsive_effects_from_pedestrians(Vector2d *F_i) {}
void compute_repulsive_effects_from_borders(Vector2d *F_i) {}
// F_i is the current position resp. direction vector of pedestrian p in time i?
void compute_acceleration_term(Vector2d *F_i, Vector2d curr, Vector2d next) {
// get curr pos --> probably no needed, can be read in F_i
// get next pos --> call shortest path --> how to encode map?
// get desired velocity
// desired speed * desired direction
// get actual velocity
// actual speed * actual direction
// TODO: how to get next node?
// acceleration * desired speed
double v_desired = 0.0;
double v_actual = 0.0;
double res = (1 / tau) * (v_desired - v_actual);
}
Vector2d get_next_node(Vector2d curr_pos, Vector2d map[]) {
// dummy element
return Vector2d(curr_pos.x + 1.0, curr_pos.y + 1.0);
}
// return the direction between two nodes along the shortest path
Vector2d get_direction(Vector2d curr_pos, Vector2d next_pos) {
double x, y, x1, x2, y1, y2;
x1 = curr_pos.x;
x2 = next_pos.x;
y1 = curr_pos.y;
y2 = next_pos.y;
x = (x2 - x1) / abs(x2 - x1);
y = (y2 - y1) / abs(y2 - y1);
return Vector2d(x, y);
}
void compute_repulsive_effects_from_pedestrians(Vector2d *F_i) {
}
void compute_repulsive_effects_from_borders(Vector2d *F_i) {
}
// Return an array of doubles
double *w(Vector2d e, Vector2d f) {